版本信息
Forge版本: 1.15.2-31.1.0
Minecraft版本: 1.15.2
错误情况简述
RightClickBlock会成双成对的被调用
报错日志
[09:16:51] [Server thread/INFO] [STDOUT/]: [com.example.examplemod.handler.PlayerHandler:onRightClickBlock:16]: 999
[09:16:51] [Server thread/INFO] [STDOUT/]: [com.example.examplemod.handler.PlayerHandler:onRightClickBlock:16]: 999
[09:16:51] [Render thread/INFO] [minecraft/NewChatGui]: [CHAT] 你右键了花岗岩
[09:16:51] [Render thread/INFO] [minecraft/NewChatGui]: [CHAT] 你右键了花岗岩
相关代码
PlayerHandler.java
@Mod.EventBusSubscriber
public class PlayerHandler
{
@SubscribeEvent
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event){
if(event.getWorld() instanceof ServerWorld){
System.out.println(999);
ITextComponent text = event.getWorld().getBlockState(event.getPos()).getBlock().getNameTextComponent();
event.getPlayer().sendMessage(new StringTextComponent("你右键了").appendSibling(text));
}
}
}