Example #1
0
 /** 当实体走过方块时调用此方法。 */
 @Override
 public void onEntityWalking(World world, int posX, int posY, int posZ, Entity entity) {
   super.onEntityWalking(world, posX, posY, posZ, entity);
   TileEntityTrap tile = (TileEntityTrap) world.getTileEntity(posX, posY, posZ);
   if (entity instanceof EntityPlayer
       && ((EntityPlayer) entity).getDisplayName().equals(tile.ownerName)) {
     if (!world.isRemote) {
       ((EntityPlayer) entity)
           .addChatComponentMessage(
               new ChatComponentText(StatCollector.translateToLocal("keycraft.prompt.yourtrap")));
     }
   } else {
     world.removeTileEntity(posX, posY, posZ);
     world.setBlock(posX, posY, posZ, Blocks.cactus);
   }
 }