コード例 #1
0
 // Extract to NBT
 public boolean writenbt(String[] nbtOperations) {
   try {
     NBTTagCompound entityNBT = new NBTTagCompound();
     entity.writeToNBT(entityNBT);
     new NBTWriter(nbtOperations).writeToNBT(entityNBT);
     entity.readFromNBT(entityNBT);
     return true;
   } catch (IllegalFormatException e) {
     JASLog.log().severe("Skipping NBT Write due to %s", e.getMessage());
   } catch (IllegalArgumentException e) {
     JASLog.log().severe("Skipping NBT Write due to %s", e.getMessage());
   }
   return false;
 }
コード例 #2
0
  public ItemStack compact(EntityLiving entity) {
    int id = EntityList.getEntityID(entity);
    ItemStack holder = new ItemStack(CompactMobsItems.fullMobHolder, 1);
    NBTTagCompound nbttag = holder.stackTagCompound;
    if (nbttag == null) {
      nbttag = new NBTTagCompound();
    }
    nbttag.setInteger("entityId", id);

    if (entity instanceof EntityAgeable) {
      EntityAgeable entityAge = (EntityAgeable) entity;
      nbttag.setInteger("entityGrowingAge", entityAge.getGrowingAge());
    }

    if (entity instanceof EntitySheep) {
      EntitySheep entitySheep = (EntitySheep) entity;
      nbttag.setBoolean("entitySheared", entitySheep.getSheared());
      nbttag.setInteger("entityColor", entitySheep.getFleeceColor());
    }

    if (CompactMobsCore.instance.useFullTagCompound) {
      NBTTagCompound entityTags = new NBTTagCompound();

      NBTTagCompound var2 = new NBTTagCompound();
      entity.writeToNBT(var2);

      nbttag.setCompoundTag("entityTags", var2);
      CompactMobsCore.instance.cmLog.info(var2.toString());
    }

    String name = entity.getEntityName();
    nbttag.setString("name", name);
    holder.setItemDamage(id);

    holder.setTagCompound(nbttag);
    entity.worldObj.removeEntity(entity);
    return holder;
  }