龙头 | ClassCastException 无法投射为宝箱
Spigot | ClassCastException cannot Cast as chest
为什么说不能把方块当作箱子?我之前创建过它...
Could not pass event PlayerDeathEvent to FactionsCSN v1.0-SNAPSHOT
java.lang.ClassCastException: org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock cannot be cast to org.bukkit.block.Chest
at creepans.factions.dims.GhostDimListener.onPlayerDeath(GhostDimListener.java:43)
看到这里,先把Type设置为Chest,然后在同一位置的方块必须是箱子
world.getBlockAt(loc).setType(Material.CHEST);
Chest crate = (Chest) world.getBlockAt(loc);
您需要将方块 state 转换为 Chest
,而不是方块本身。请尝试 Chest crate = (Chest) world.getBlockAt(loc).getState();
。
为什么说不能把方块当作箱子?我之前创建过它...
Could not pass event PlayerDeathEvent to FactionsCSN v1.0-SNAPSHOT
java.lang.ClassCastException: org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock cannot be cast to org.bukkit.block.Chest
at creepans.factions.dims.GhostDimListener.onPlayerDeath(GhostDimListener.java:43)
看到这里,先把Type设置为Chest,然后在同一位置的方块必须是箱子
world.getBlockAt(loc).setType(Material.CHEST);
Chest crate = (Chest) world.getBlockAt(loc);
您需要将方块 state 转换为 Chest
,而不是方块本身。请尝试 Chest crate = (Chest) world.getBlockAt(loc).getState();
。