net.minecraft.entity.Entity.serializeNBT()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中net.minecraft.entity.Entity.serializeNBT()方法的一些代码示例,展示了Entity.serializeNBT()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.serializeNBT()方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:serializeNBT

Entity.serializeNBT介绍

暂无

代码示例

代码示例来源:origin: McJtyMods/TheOneProbe

public ElementEntity(Entity entity, IEntityStyle style) {
  if (entity instanceof EntityPlayer) {
    EntityPlayer player = (EntityPlayer) entity;
    entityNBT = null;
    playerID = player.getEntityId();
  } else {
    entityNBT = entity.serializeNBT();
    playerID = null;
  }
  this.entityName = EntityList.getEntityString(entity);
  this.style = style;
}

代码示例来源:origin: CoFH/ThermalExpansion

private void attemptCapture(RayTraceResult traceResult) {
  BlockPos pos = new BlockPos(traceResult.hitVec);
  if (ServerHelper.isServerWorld(world)) {
    boolean noAccess = traceResult.sideHit != null && getThrower() instanceof EntityPlayer && !((EntityPlayer) getThrower()).canPlayerEdit(pos, traceResult.sideHit, blockCheck);
    if (traceResult.entityHit == null || EntityList.getKey(traceResult.entityHit) == null || !ItemMorb.validMobs.contains(EntityList.getKey(traceResult.entityHit).toString()) || noAccess) {
      ItemMorb.dropMorb(type, null, world, pos);
      this.setDead();
      return;
    }
    NBTTagCompound tag = traceResult.entityHit.serializeNBT();
    ((WorldServer) world).spawnParticle(EnumParticleTypes.CLOUD, pos.getX() + 0.5, pos.getY() + 0.2, pos.getZ() + 0.5, 2, 0, 0, 0, 0.0, 0);
    ItemMorb.dropMorb(type, tag, world, pos);
    traceResult.entityHit.setDead();
    this.setDead();
  }
}

相关文章

微信公众号

最新文章

更多

Entity类方法