Java:
@SubscribeEvent
public void damagePlayer(LivingHurtEvent event) {
if(event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)event.getEntityLiving();
ItemStack stack = player.inventory.armorItemInSlot(3);
if (stack.getItem().getUnlocalizedName() != "minecraft:air" && stack.getItem() == RegistryHandler.MAGIC_ARMOR_HEAD) {
if(event.getSource().isMagicDamage()) {
event.setAmount((event.getAmount()/1.25f));
}
}
}
}
- Краш-лог
-
---- Minecraft Crash Report ----
// Who set us up the TNT?
Time: 7/17/20 11:13 PM
Description: Ticking entity
java.lang.ClassCastException: net.minecraft.entity.passive.EntitySheep cannot be cast to net.minecraft.entity.player.EntityPlayer
at vados.mod.items.armor.ItemMagicArmor.damagePlayer(ItemMagicArmor.java:39)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_20_ItemMagicArmor_damagePlayer_LivingHurtEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1410)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:926)
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:75)
at net.minecraft.potion.Potion.affectEntity(Potion.java:133)
at net.minecraft.entity.projectile.EntityPotion.applySplash(EntityPotion.java:192)
at net.minecraft.entity.projectile.EntityPotion.onImpact(EntityPotion.java:135)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:249)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1996)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:832)
at net.minecraft.world.World.updateEntity(World.java:1958)
at net.minecraft.world.World.updateEntities(World.java:1762)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:613)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:767)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
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 vados.mod.items.armor.ItemMagicArmor.damagePlayer(ItemMagicArmor.java:39)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_20_ItemMagicArmor_damagePlayer_LivingHurtEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1410)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:926)
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:75)
at net.minecraft.potion.Potion.affectEntity(Potion.java:133)
at net.minecraft.entity.projectile.EntityPotion.applySplash(EntityPotion.java:192)
at net.minecraft.entity.projectile.EntityPotion.onImpact(EntityPotion.java:135)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:249)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1996)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:832)
at net.minecraft.world.World.updateEntity(World.java:1958)
-- Entity being ticked --
Details:
Entity Type: minecraft:potion (net.minecraft.entity.projectile.EntityPotion)
Entity ID: 649
Entity Name: Зелье
Entity's Exact location: 269.50, 64.64, 197.03
Entity's Block location: World: (269,64,197), Chunk: (at 13,4,5 in 16,12; contains blocks 256,0,192 to 271,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: 0.42, -0.32, -0.18
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:1762)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:613)
-- Affected level --
Details:
Level name: Новый мир
All players: 1 total; [EntityPlayerMP['Player787'/199, l='Новый мир', x=266.41, y=64.00, z=198.36]]
Chunk stats: ServerChunkCache: 626 Drop: 0
Level seed: -2867710312426457120
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options:
Level spawn location: World: (240,64,196), Chunk: (at 0,4,4 in 15,12; contains blocks 240,0,192 to 255,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 2659 game time, 2659 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 62518 (now: false), thunder time: 108546 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:767)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
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_231, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 224354008 bytes (213 MB) / 904921088 bytes (863 MB) up to 1897922560 bytes (1810 MB)
JVM Flags: 0 total;
IntCache: cache: 0, tcache: 0, allocated: 20, tallocated: 86
FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 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 |
|:------ |:--------- |:------------ |:------------------------------------------------------------------ |:--------- |
| LCHIJA | minecraft | 1.12.2 | minecraft.jar | None |
| LCHIJA | mcp | 9.42 | minecraft.jar | None |
| LCHIJA | FML | 8.0.99.99 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCHIJA | forge | 14.23.5.2854 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCHIJA | vados | 1.0 | main | None |
Loaded coremods (and transformers):
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player787'/199, l='Новый мир', x=266.41, y=64.00, z=198.36]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'
Краш-лог:
---- Minecraft Crash Report ----
// Who set us up the TNT?
Time: 7/17/20 11:13 PM
Description: Ticking entity
java.lang.ClassCastException: net.minecraft.entity.passive.EntitySheep cannot be cast to net.minecraft.entity.player.EntityPlayer
at vados.mod.items.armor.ItemMagicArmor.damagePlayer(ItemMagicArmor.java:39)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_20_ItemMagicArmor_damagePlayer_LivingHurtEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1410)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:926)
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:75)
at net.minecraft.potion.Potion.affectEntity(Potion.java:133)
at net.minecraft.entity.projectile.EntityPotion.applySplash(EntityPotion.java:192)
at net.minecraft.entity.projectile.EntityPotion.onImpact(EntityPotion.java:135)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:249)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1996)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:832)
at net.minecraft.world.World.updateEntity(World.java:1958)
at net.minecraft.world.World.updateEntities(World.java:1762)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:613)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:767)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
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 vados.mod.items.armor.ItemMagicArmor.damagePlayer(ItemMagicArmor.java:39)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_20_ItemMagicArmor_damagePlayer_LivingHurtEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
at net.minecraftforge.common.ForgeHooks.onLivingHurt(ForgeHooks.java:604)
at net.minecraft.entity.EntityLivingBase.damageEntity(EntityLivingBase.java:1410)
at net.minecraft.entity.EntityLivingBase.attackEntityFrom(EntityLivingBase.java:926)
at net.minecraft.entity.passive.EntityAnimal.attackEntityFrom(EntityAnimal.java:75)
at net.minecraft.potion.Potion.affectEntity(Potion.java:133)
at net.minecraft.entity.projectile.EntityPotion.applySplash(EntityPotion.java:192)
at net.minecraft.entity.projectile.EntityPotion.onImpact(EntityPotion.java:135)
at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:249)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1996)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:832)
at net.minecraft.world.World.updateEntity(World.java:1958)
-- Entity being ticked --
Details:
Entity Type: minecraft:potion (net.minecraft.entity.projectile.EntityPotion)
Entity ID: 649
Entity Name: Зелье
Entity's Exact location: 269.50, 64.64, 197.03
Entity's Block location: World: (269,64,197), Chunk: (at 13,4,5 in 16,12; contains blocks 256,0,192 to 271,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: 0.42, -0.32, -0.18
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:1762)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:613)
-- Affected level --
Details:
Level name: Новый мир
All players: 1 total; [EntityPlayerMP['Player787'/199, l='Новый мир', x=266.41, y=64.00, z=198.36]]
Chunk stats: ServerChunkCache: 626 Drop: 0
Level seed: -2867710312426457120
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options:
Level spawn location: World: (240,64,196), Chunk: (at 0,4,4 in 15,12; contains blocks 240,0,192 to 255,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 2659 game time, 2659 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 62518 (now: false), thunder time: 108546 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:767)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
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_231, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 224354008 bytes (213 MB) / 904921088 bytes (863 MB) up to 1897922560 bytes (1810 MB)
JVM Flags: 0 total;
IntCache: cache: 0, tcache: 0, allocated: 20, tallocated: 86
FML: MCP 9.42 Powered by Forge 14.23.5.2854 5 mods loaded, 5 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 |
|:------ |:--------- |:------------ |:------------------------------------------------------------------ |:--------- |
| LCHIJA | minecraft | 1.12.2 | minecraft.jar | None |
| LCHIJA | mcp | 9.42 | minecraft.jar | None |
| LCHIJA | FML | 8.0.99.99 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCHIJA | forge | 14.23.5.2854 | forge-1.12.2-14.23.5.2854_mapped_snapshot_20171003-1.12-recomp.jar | None |
| LCHIJA | vados | 1.0 | main | None |
Loaded coremods (and transformers):
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player787'/199, l='Новый мир', x=266.41, y=64.00, z=198.36]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'