版本信息
你使用的IDE:IntelliJ IDEA
你使用的IDE版本:2020.1
Forge版本: 31.1.46
Minecraft版本:1.15.2
Mapping 文件版本:20200520
错误情况简述
我给原版玩家增加了两个属性job
和team
来进行一些判定,但是在使用.getAttributeMap().getEntityAttribute(...).getValue()
的时候报错。
报错日志
[14:48:47] [Render thread/FATAL] [minecraft/Minecraft]: Reported exception thrown!
net.minecraft.crash.ReportedException: Colliding entity with block
at net.minecraft.world.World.guardEntityTick(World.java:591) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.world.ClientWorld.tickEntities(ClientWorld.java:152) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1457) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:942) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.run(Minecraft.java:559) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {}
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {}
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {}
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {}
at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {}
at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {}
Caused by: java.lang.NullPointerException
at com.uss_shenzhou.rainbow6.blocks.BarbedWire.onEntityCollision(BarbedWire.java:41) ~[main/:?] {re:classloading}
at net.minecraft.block.BlockState.onEntityCollision(BlockState.java:282) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:877) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.entity.Entity.move(Entity.java:615) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.move(ClientPlayerEntity.java:917) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:2040) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.travel(PlayerEntity.java:1622) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2453) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.livingTick(PlayerEntity.java:534) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.livingTick(ClientPlayerEntity.java:835) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2264) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:237) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.tick(ClientPlayerEntity.java:220) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.world.ClientWorld.updateEntity(ClientWorld.java:182) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.world.World.guardEntityTick(World.java:586) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
... 16 more
[14:48:47] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:110]: ---- Minecraft Crash Report ----
// Who set us up the TNT?
Time: 20-5-21 下午2:48
Description: Colliding entity with block
java.lang.NullPointerException: Colliding entity with block
at com.uss_shenzhou.rainbow6.blocks.BarbedWire.onEntityCollision(BarbedWire.java:41) ~[main/:?] {re:classloading}
at net.minecraft.block.BlockState.onEntityCollision(BlockState.java:282) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:877) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.entity.Entity.move(Entity.java:615) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.move(ClientPlayerEntity.java:917) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:2040) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.travel(PlayerEntity.java:1622) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2453) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.livingTick(PlayerEntity.java:534) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.livingTick(ClientPlayerEntity.java:835) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2264) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading}
at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:237) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.entity.player.ClientPlayerEntity.tick(ClientPlayerEntity.java:220) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.world.ClientWorld.updateEntity(ClientWorld.java:182) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.world.World.guardEntityTick(World.java:586) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
at net.minecraft.client.world.ClientWorld.tickEntities(ClientWorld.java:152) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1457) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:942) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.run(Minecraft.java:559) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {}
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {}
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {}
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {}
at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {}
at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {}
at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar:?] {}
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Thread: Render thread
Stacktrace:
at com.uss_shenzhou.rainbow6.blocks.BarbedWire.onEntityCollision(BarbedWire.java:41)
at net.minecraft.block.BlockState.onEntityCollision(BlockState.java:282)
-- Block being collided with --
Details:
Block: Block{rainbow6:barbedwire}
Block location: World: (209,4,-315), Chunk: (at 1,0,5 in 13,-20; contains blocks 208,0,-320 to 223,255,-305), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
Stacktrace:
at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:877)
-- Entity being checked for collision --
Details:
Entity Type: minecraft:player (net.minecraft.client.entity.player.ClientPlayerEntity)
Entity ID: 19
Entity Name: Dev
Entity's Exact location: 209.98, 4.16, -313.72
Entity's Block location: World: (209,4,-314), Chunk: (at 1,0,6 in 13,-20; contains blocks 208,0,-320 to 223,255,-305), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
Entity's Momentum: -0.09, -0.00, -0.19
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.entity.Entity.move(Entity.java:615)
at net.minecraft.client.entity.player.ClientPlayerEntity.move(ClientPlayerEntity.java:917)
at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:2040)
at net.minecraft.entity.player.PlayerEntity.travel(PlayerEntity.java:1622)
at net.minecraft.entity.LivingEntity.livingTick(LivingEntity.java:2453)
at net.minecraft.entity.player.PlayerEntity.livingTick(PlayerEntity.java:534)
at net.minecraft.client.entity.player.ClientPlayerEntity.livingTick(ClientPlayerEntity.java:835)
at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2264)
at net.minecraft.entity.player.PlayerEntity.tick(PlayerEntity.java:237)
at net.minecraft.client.entity.player.ClientPlayerEntity.tick(ClientPlayerEntity.java:220)
at net.minecraft.client.world.ClientWorld.updateEntity(ClientWorld.java:182)
-- Entity being ticked --
Details:
Entity Type: minecraft:player (net.minecraft.client.entity.player.ClientPlayerEntity)
Entity ID: 19
Entity Name: Dev
Entity's Exact location: 209.98, 4.16, -313.72
Entity's Block location: World: (209,4,-314), Chunk: (at 1,0,6 in 13,-20; contains blocks 208,0,-320 to 223,255,-305), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
Entity's Momentum: -0.09, -0.00, -0.19
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.world.World.guardEntityTick(World.java:586)
at net.minecraft.client.world.ClientWorld.tickEntities(ClientWorld.java:152)
-- Affected level --
Details:
All players: 1 total; [ClientPlayerEntity['Dev'/19, l='MpServer', x=209.98, y=4.16, z=-313.72]]
Chunk stats: Client Chunk Cache: 529, 324
Level dimension: DimensionType{minecraft:overworld}
Level name: MpServer
Level seed: 5923470984027960334
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: {}
Level spawn location: World: (176,4,-192), Chunk: (at 0,0,0 in 11,-12; contains blocks 176,0,-192 to 191,255,-177), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
Level time: 492605 game time, 1163 day time
Known server brands:
Level was modded: false
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Server brand: forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:457)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1840)
at net.minecraft.client.Minecraft.run(Minecraft.java:573)
at net.minecraft.client.main.Main.main(Main.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54)
at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72)
at cpw.mods.modlauncher.Launcher.run(Launcher.java:81)
at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102)
-- System Details --
Details:
Minecraft Version: 1.15.2
Minecraft Version ID: 1.15.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_241, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 1235695208 bytes (1178 MB) / 2050490368 bytes (1955 MB) up to 3793747968 bytes (3618 MB)
CPUs: 4
JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
ModLauncher: 5.0.0-milestone.4+67+b1a340b
ModLauncher launch target: fmluserdevclient
ModLauncher naming: mcp
ModLauncher services:
/eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE
/forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE
/forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE
/accesstransformers-2.0.4-shadowed.jar accesstransformer PLUGINSERVICE
/forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE
/forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE
/forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE
FML: 31.1
Forge: net.minecraftforge:31.1.46
FML Language Providers:
[email protected]
minecraft@1
Mod List:
client-extra.jar Minecraft {[email protected] DONE}
forge-1.15.2-31.1.46_mapped_snapshot_20200508-1.15.1-recomp.jar Forge {[email protected] DONE}
main Rainbow6siege {[email protected] DONE}
Launched Version: MOD_DEV
Backend library: LWJGL version 3.2.2 build 10
Backend API: GeForce GTX 1050 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 442.59, NVIDIA Corporation
GL Caps: Using framebuffer using OpenGL 3.0
Using VBOs: Yes
Is Modded: Definitely; Client brand changed to 'forge'
Type: Client (map_client.txt)
Resource Packs:
Current Language: 简体中文 (中国)
CPU: 4x Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
[14:48:47] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:110]: #@!@# Game crashed! Crash report saved to: #@!@# F:\MC mod\forge-1.14.4-28.2.3-mdk\run\.\crash-reports\crash-2020-05-21_14.48.47-client.txt
AL lib: (EE) alc_cleanup: 1 device not closed
Process finished with exit code -1
相关代码
BarbedWire.java
team判定有关部分
参考了原版的浆果SweetBerryBushBlock.java
@Override
public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
if (entityIn instanceof PlayerEntity && ((PlayerEntity) entityIn).getAttributes().getAttributeInstance(OPERATOR_TEAM).getValue()==1){
entityIn.setMotionMultiplier(state, new Vec3d(0.85d, 0.4D,0.85d));
}
}
Utils.java
增加属性的部分
public static final IAttribute OPERATOR_JOB = new RangedAttribute(null,"r6_operator_job",0,0,54);
//0:has not chose & spectator; 1~27:Attackers in turn; 28~54:Defenders in turn
public static final IAttribute OPERATOR_TEAM = new RangedAttribute(null,"r6_operator_team",0,-1,1);
//-1:defender 0:spectator 1:attacker
@SubscribeEvent
public static void entityInit(PlayerEvent.PlayerLoggedInEvent event){
final PlayerEntity player = event.getPlayer();
player.getAttributes().registerAttribute(OPERATOR_JOB);
player.getAttributes().registerAttribute(OPERATOR_TEAM);
}
查到的资料
主要参照https://harbinger.covertdragon.team/chapter-08/attribute/