Ejemplo n.º 1
0
 @Override
 public void writeToNBT(NBTTagCompound compound) {
   compound.setInteger("orientation", this.orientation.ordinal());
   compound.setInteger("parts_size", this.registeredDamParts.size());
   // TODO registeredDamParts
   super.writeToNBT(compound);
 }
Ejemplo n.º 2
0
  public static FMLProxyPacket createPacketForTEntCommand(TileEntity tEnt, NBTTagCompound data) {
    /*ByteArrayOutputStream bos = new ByteArrayOutputStream(); //was ...(140);
    DataOutputStream dos = new DataOutputStream(bos);*/

    ByteBuf byteBuf = Unpooled.buffer();
    NBTTagCompound nbtSendData = new NBTTagCompound();

    try {
      nbtSendData.setString("command", "CoroAI_TEntCmd");
      nbtSendData.setInteger("dimID", tEnt.getWorldObj().provider.dimensionId);
      nbtSendData.setInteger("x", tEnt.xCoord);
      nbtSendData.setInteger("y", tEnt.yCoord);
      nbtSendData.setInteger("z", tEnt.zCoord);
      nbtSendData.setTag("data", data);
      // ByteBufUtils.writeUTF8String(byteBuf, "CoroAI_TEntCmd");
      /*byteBuf.writeInt(tEnt.getWorldObj().provider.dimensionId);
      byteBuf.writeInt(tEnt.xCoord);
      byteBuf.writeInt(tEnt.yCoord);
      byteBuf.writeInt(tEnt.zCoord);*/
      ByteBufUtils.writeTag(byteBuf, nbtSendData);
      // writeNBTTagCompound(data, dos);

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    /*Packet250CustomPayload pkt = new Packet250CustomPayload();
    pkt.channel = "CoroAI_TEntCmd";
    pkt.data = bos.toByteArray();
    pkt.length = bos.size();*/

    return new FMLProxyPacket(byteBuf, CoroAI.eventChannelName);
  }
Ejemplo n.º 3
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int idk,
      float what,
      float these,
      float are) {
    ItemStack playerItem = player.getCurrentEquippedItem();

    if (playerItem != null) {
      if (playerItem.getItem() instanceof TelepositionFocus) {
        SoulNetworkHandler.checkAndSetItemPlayer(playerItem, player);

        if (playerItem.getTagCompound() == null) {
          playerItem.setTagCompound(new NBTTagCompound());
        }

        NBTTagCompound itemTag = playerItem.getTagCompound();
        itemTag.setInteger("xCoord", x);
        itemTag.setInteger("yCoord", y);
        itemTag.setInteger("zCoord", z);
        itemTag.setInteger("dimensionId", world.provider.dimensionId);
        return true;
      }
    }
    player.openGui(AlchemicalWizardry.instance, 1, world, x, y, z);
    return true;
  }
Ejemplo n.º 4
0
  public NBTTagCompound writeCrucibleToNBT(TECrucible te) {
    NBTTagCompound nbt = new NBTTagCompound();

    nbt.setInteger("temp", te.temperature);

    NBTTagList nbttaglist = new NBTTagList();
    Iterator iter = te.metals.values().iterator();
    while (iter.hasNext()) {
      MetalPair m = (MetalPair) iter.next();
      if (m != null) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setInteger("ID", m.type.IngotID);
        nbttagcompound1.setFloat("AmountF", m.amount);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }
    nbt.setTag("Metals", nbttaglist);

    nbttaglist = new NBTTagList();
    for (int i = 0; i < te.storage.length; i++) {
      if (te.storage[i] != null) {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setByte("Slot", (byte) i);
        te.storage[i].writeToNBT(nbttagcompound1);
        nbttaglist.appendTag(nbttagcompound1);
      }
    }

    nbt.setTag("Items", nbttaglist);

    return nbt;
  }
 @Override
 public void addInformation(
     ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
   if (par1ItemStack.getTagCompound() == null) {
     par1ItemStack.setTagCompound(new NBTTagCompound());
   }
   NBTTagCompound tag = par1ItemStack.getTagCompound();
   if (tag.getString("Creator") == "") {
     tag.setString("Creator", par2EntityPlayer.username);
   }
   this.currentCharge = tag.getInteger("CurrentCharge");
   tag.setInteger("MaxStorage", this.maxStorage);
   this.maxStorage = tag.getInteger("MaxStorage");
   tag.setInteger("RechargeRate", this.rechargeRatePerTick);
   this.rechargeRatePerTick = tag.getInteger("RechargeRate");
   dimensionTravel = tag.getInteger("Dimension");
   x = tag.getInteger("posX");
   y = tag.getInteger("posY");
   z = tag.getInteger("posZ");
   if (x != null && y != null && z != null) {
     par3List.add("X: " + x.toString());
     par3List.add("Y: " + y.toString());
     par3List.add("Z: " + z.toString());
     par3List.add("Dimension: " + dimensionTravel);
     par3List.add(this.currentCharge + "/" + this.maxStorage + " MyJ");
     par3List.add("Creator: " + tag.getString("Creator"));
   }
 }
Ejemplo n.º 6
0
 @Override
 public void writeToNBT(NBTTagCompound nbt) {
   super.writeToNBT(nbt);
   nbt.setInteger("dayHarvested", dayHarvested);
   nbt.setInteger("dayFruited", dayFruited);
   nbt.setBoolean("hasFruit", hasFruit);
 }
 public boolean onItemUseFirst(
     GT_MetaBase_Item aItem,
     ItemStack aStack,
     EntityPlayer aPlayer,
     World aWorld,
     int aX,
     int aY,
     int aZ,
     int aSide,
     float hitX,
     float hitY,
     float hitZ) {
   if ((aPlayer instanceof EntityPlayerMP)) {
     TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
     if (((tTileEntity instanceof IInventory))
         && (!((IInventory) tTileEntity).isUseableByPlayer(aPlayer))) {
       return false;
     }
     if (((tTileEntity instanceof IGregTechDeviceInformation))
         && (((IGregTechDeviceInformation) tTileEntity).isGivingInformation())) {
       GT_Utility.setStack(aStack, ItemList.NC_SensorCard.get(aStack.stackSize, new Object[0]));
       NBTTagCompound tNBT = aStack.getTagCompound();
       if (tNBT == null) {
         tNBT = new NBTTagCompound();
       }
       tNBT.setInteger("x", aX);
       tNBT.setInteger("y", aY);
       tNBT.setInteger("z", aZ);
       aStack.setTagCompound(tNBT);
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 8
0
  /** write data to NBTTagCompound from this MapDataBase, similar to Entities and TileEntities */
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    // CraftBukkit start
    // LavaBukkit TODO: is it necessary to track UUID, since LB should ensure a stable
    // dimension/world mapping?
    if (this.uniqueId == null) {
      for (org.bukkit.World world : server.getWorlds()) {
        CraftWorld cWorld = (CraftWorld) world;
        if (cWorld.getHandle().provider.dimensionId == this.dimension) {
          this.uniqueId = cWorld.getUID();
          break;
        }
      }
    }
    /* Perform a second check to see if a matching world was found, this is a necessary
    change incase Maps are forcefully unlinked from a World and lack a UID.*/
    if (this.uniqueId != null) {
      par1NBTTagCompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
      par1NBTTagCompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
    }
    // CraftBukkit end

    par1NBTTagCompound.setInteger("dimension", this.dimension);
    par1NBTTagCompound.setInteger("xCenter", this.xCenter);
    par1NBTTagCompound.setInteger("zCenter", this.zCenter);
    par1NBTTagCompound.setByte("scale", this.scale);
    par1NBTTagCompound.setShort("width", (short) 128);
    par1NBTTagCompound.setShort("height", (short) 128);
    par1NBTTagCompound.setByteArray("colors", this.colors);
  }
Ejemplo n.º 9
0
 @Override
 public void createInitNBT(NBTTagCompound nbt) {
   nbt.setByte("rotation", rotation);
   nbt.setBoolean("sealed", sealed);
   nbt.setInteger("fluid", fluid != null ? fluid.fluidID : -1);
   nbt.setInteger("fluidAmount", fluid != null ? fluid.amount : 0);
 }
Ejemplo n.º 10
0
  public static boolean moveBlock(
      World world, Coord src, Coord tgt, boolean allowBlockReplacement) {
    if (!world.isRemote
        && !src.isAirBlock(world)
        && (tgt.isAirBlock(world) || allowBlockReplacement)) {
      int blockID = src.getBlockID(world);
      int metadata = src.getBlockMetadata(world);

      world.setBlock(tgt.x, tgt.y, tgt.z, blockID, metadata, BlockNotifyFlags.ALL);

      if (world.blockHasTileEntity(src.x, src.y, src.z)) {
        TileEntity te = world.getBlockTileEntity(src.x, src.y, src.z);
        if (te != null) {
          NBTTagCompound nbt = new NBTTagCompound();
          te.writeToNBT(nbt);

          nbt.setInteger("x", tgt.x);
          nbt.setInteger("y", tgt.y);
          nbt.setInteger("z", tgt.z);

          te = world.getBlockTileEntity(tgt.x, tgt.y, tgt.z);
          if (te != null) te.readFromNBT(nbt);
        }
      }

      world.setBlockToAir(src.x, src.y, src.z);
      return true;
    }
    return false;
  }
Ejemplo n.º 11
0
  @Override
  public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
    nbt.setByte("mode", (byte) mode.ordinal());
    nbt.setInteger("x", x);
    nbt.setInteger("y", y);
    nbt.setInteger("z", z);

    if (schematic != null) {
      NBTTagCompound schematicNBT = new NBTTagCompound();
      SchematicFactory.getFactory(schematic.getClass())
          .saveSchematicToWorldNBT(schematicNBT, schematic, registry);
      nbt.setTag("schematic", schematicNBT);
    }

    NBTTagList nbtStacks = new NBTTagList();

    if (stackConsumed != null) {
      for (ItemStack stack : stackConsumed) {
        NBTTagCompound nbtStack = new NBTTagCompound();
        stack.writeToNBT(nbtStack);
        nbtStacks.appendTag(nbtStack);
      }
    }

    nbt.setTag("stackConsumed", nbtStacks);
  }
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    tags.setBoolean(key, true);
    addEnchantment(tool, Enchantment.silkTouch, 1);

    int modifiers = tags.getInteger("Modifiers");
    modifiers -= 1;
    tags.setInteger("Modifiers", modifiers);

    int attack = tags.getInteger("Attack");
    attack -= 3;
    if (attack < 0) attack = 0;
    tags.setInteger("Attack", attack);

    int miningSpeed = tags.getInteger("MiningSpeed");
    miningSpeed -= 300;
    if (miningSpeed < 0) miningSpeed = 0;
    tags.setInteger("MiningSpeed", miningSpeed);

    if (tags.hasKey("MiningSpeed2")) {
      int miningSpeed2 = tags.getInteger("MiningSpeed2");
      miningSpeed2 -= 300;
      if (miningSpeed2 < 0) miningSpeed2 = 0;
      tags.setInteger("MiningSpeed2", miningSpeed2);
    }

    addToolTip(tool, color + tooltipName, color + key);
  }
Ejemplo n.º 13
0
  public static ItemStack chargeHealth(
      ItemStack stack, World world, EntityPlayer player, String tag) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    NBTTagCompound nbtData = stack.getTagCompound();
    if (nbtData == null) {
      stack.getTagCompound().setInteger(tag, 0);
    }
    if (player.isSneaking()) {
      int points = stack.getTagCompound().getInteger(tag);
      if (points != 0) {
        int current = (int) player.getHealth();
        int max = (int) player.getMaxHealth();
        if (current != max & (current < max)) {
          int used = max - current;
          if (!(points - used < 0)) {
            nbtData.setInteger(tag, points - used);
            player.setHealth(player.getMaxHealth());
          } else if ((points - used < 0)) {
            nbtData.setInteger(tag, 0);
            player.setHealth(nbtData.getInteger(tag) + current);
          }
        }
      }
    } else {
      FontHelper.sendMessage(
          FontHelper.translate("points.health") + ": " + stack.getTagCompound().getInteger(tag),
          world,
          player);
    }
    return stack;
  }
Ejemplo n.º 14
0
  public static ItemStack chargeHunger(
      ItemStack stack, World world, EntityPlayer player, String tag) {

    if (!stack.hasTagCompound()) {
      stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound nbtData = stack.getTagCompound();
    if (nbtData == null) {
      stack.getTagCompound().setInteger(tag, 0);
    }
    int points = stack.getTagCompound().getInteger(tag);
    if (player.isSneaking()) {
      int hunger = player.getFoodStats().getFoodLevel();

      int usedpoints = 20 - hunger;

      if (!(hunger >= 20)) {
        if (points - usedpoints > 1) {
          points -= usedpoints;
          nbtData.setInteger(tag, points);
          player.getFoodStats().addStats(20, 2.0F);

        } else if (points - usedpoints < 1) {
          nbtData.setInteger(tag, 0);
          player.getFoodStats().addStats(points, 2.0F);
        }
      }
    } else if (!world.isRemote) {
      FontHelper.sendMessage(
          FontHelper.translate("points.hunger") + ": " + stack.getTagCompound().getInteger(tag),
          world,
          player);
    }
    return stack;
  }
Ejemplo n.º 15
0
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    int increase = matchingAmount(input);
    if (tags.hasKey(key)) {
      int[] keyPair = tags.getIntArray(key);
      if (keyPair[0] == max) {
        keyPair[0] += increase;
        keyPair[1] += max;
        tags.setIntArray(key, keyPair);

        int modifiers = tags.getInteger("Modifiers");
        modifiers -= 1;
        tags.setInteger("Modifiers", modifiers);
      } else {
        keyPair[0] += increase;
        tags.setIntArray(key, keyPair);
      }
      updateModTag(tool, keyPair);
    } else {
      int modifiers = tags.getInteger("Modifiers");
      modifiers -= 1;
      tags.setInteger("Modifiers", modifiers);
      String modName = "\u00a76Blaze (" + increase + "/" + max + ")";
      int tooltipIndex = addToolTip(tool, tooltipName, modName);
      int[] keyPair = new int[] {increase, max, tooltipIndex};
      tags.setIntArray(key, keyPair);
    }

    int fiery = tags.getInteger("Fiery");
    fiery += (increase);
    tags.setInteger("Fiery", fiery);
  }
Ejemplo n.º 16
0
 @Override
 public void readDataFromNetwork(ByteBuf in, byte id, NBTTagCompound nbt) {
   if (id == 0) nbt.setInteger("laserX", in.readInt());
   else if (id == 1) nbt.setInteger("laserZ", in.readInt());
   else if (id == 2) nbt.setBoolean("isRunning", in.readBoolean());
   else if (id == 3) nbt.setInteger("mode", in.readInt());
 }
Ejemplo n.º 17
0
 @Override
 public void onEnable() {
   if (mc.thePlayer.inventory.getStackInSlot(0) != null) {
     wurst.chat.error("Please clear the first slot in your hotbar.");
     setEnabled(false);
     return;
   } else if (!mc.thePlayer.capabilities.isCreativeMode) {
     wurst.chat.error("Creative mode only.");
     setEnabled(false);
     return;
   }
   ItemStack stack = new ItemStack(Items.potionitem);
   stack.setItemDamage(16384);
   NBTTagList effects = new NBTTagList();
   for (int i = 1; i <= 23; i++) {
     NBTTagCompound effect = new NBTTagCompound();
     effect.setInteger("Amplifier", Integer.MAX_VALUE);
     effect.setInteger("Duration", Integer.MAX_VALUE);
     effect.setInteger("Id", i);
     effects.appendTag(effect);
   }
   stack.setTagInfo("CustomPotionEffects", effects);
   stack.setStackDisplayName("§c§lTroll§6§lPotion");
   mc.thePlayer.sendQueue.addToSendQueue(new C10PacketCreativeInventoryAction(36, stack));
   wurst.chat.message("Potion created. Trololo!");
   setEnabled(false);
 }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int meta,
      float f1,
      float f2,
      float f3) {
    if (world.isRemote || stack.hasTagCompound()) {
      return false;
    }

    NBTTagCompound tagCompound = new NBTTagCompound();
    tagCompound.setInteger(ThermalScienceNBTTags.Dim, world.provider.dimensionId);
    tagCompound.setInteger(ThermalScienceNBTTags.XCoord, x);
    tagCompound.setInteger(ThermalScienceNBTTags.YCoord, y + 1);
    tagCompound.setInteger(ThermalScienceNBTTags.ZCoord, z);

    int yaw = (int) player.rotationYaw;

    if (yaw < 0) {
      yaw += 360;
    }

    int i = (yaw + 45) / 90;

    tagCompound.setInteger(ThermalScienceNBTTags.Yaw, (i * 90));

    stack.setTagCompound(tagCompound);
    return true;
  }
 /** Writes a tile entity to NBT. */
 @Override
 public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
   par1NBTTagCompound.setInteger("QEnergyItemBuffer", this.QEnergyItemBuffer);
   par1NBTTagCompound.setInteger("LastItemValue", this.lastItemValue);
   TileUtil.saveInventory(par1NBTTagCompound, this.inventory);
   super.writeToNBT(par1NBTTagCompound);
 }
Ejemplo n.º 20
0
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    transport.writeToNBT(nbttagcompound);
    logic.writeToNBT(nbttagcompound);

    // Save pulser if any
    if (gate != null) {
      NBTTagCompound nbttagcompoundC = new NBTTagCompound();
      gate.writeToNBT(nbttagcompoundC);
      nbttagcompound.setTag("Gate", nbttagcompoundC);
      // Wire states are stored for pipes with gates only
      for (int i = 0; i < 4; ++i)
        nbttagcompound.setBoolean("wireState[" + i + "]", broadcastSignal[i]);
      nbttagcompound.setBoolean("redstoneState", broadcastRedstone);
    }

    for (int i = 0; i < 4; ++i) nbttagcompound.setBoolean("wireSet[" + i + "]", wireSet[i]);

    for (int i = 0; i < 8; ++i) {
      nbttagcompound.setInteger(
          "action[" + i + "]", activatedActions[i] != null ? activatedActions[i].getId() : 0);
      nbttagcompound.setInteger(
          "trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].getId() : 0);
    }

    for (int i = 0; i < 8; ++i)
      if (triggerParameters[i] != null) {
        NBTTagCompound cpt = new NBTTagCompound();
        triggerParameters[i].writeToNBT(cpt);
        nbttagcompound.setTag("triggerParameters[" + i + "]", cpt);
      }
  }
 @Override
 public void writeToNBT(NBTTagCompound tag) {
   tag.setInteger("pulsesCompleted", _pulsesCompleted);
   tag.setInteger("ticksCompleted", _ticksCompleted);
   tag.setBoolean("isActive", _isActive);
   tag.setBoolean("lastClockState", _lastClockState);
 }
Ejemplo n.º 22
0
  @Override
  public int charge(ItemStack item, int amount, boolean flag) {

    if (item == null) return 0;

    NBTTagCompound nbt = item.getTagCompound();
    int charge = 0;
    int increase = 0;
    if (nbt != null && nbt.hasKey("charge")) {
      charge = nbt.getInteger("charge");
    }

    int i = this.getMaxAmount(item) - charge;
    Math.min(i, 0);

    increase = Math.min(amount, i);

    if (flag) {
      if (nbt != null) {
        nbt.setInteger("charge", (charge + increase));
        item.setTagCompound(nbt);
      } else {
        NBTTagCompound nbt2 = new NBTTagCompound();
        nbt2.setInteger("charge", (charge + increase));
        item.setTagCompound(nbt2);
      }
    }

    return increase;
  }
  @Override
  public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);

    tag.setInteger("facing", facing.ordinal());
    tag.setInteger("linked", linkedDir.ordinal());
  }
Ejemplo n.º 24
0
  @Override
  public int discharge(ItemStack item, int amount, boolean flag) {

    if (item == null) return 0;

    NBTTagCompound nbt = item.getTagCompound();
    int charge = 0;
    int reduce = 0;
    if (nbt != null && nbt.hasKey("charge")) {
      charge = nbt.getInteger("charge");
    }

    reduce = Math.min(amount, charge);

    if (flag) {
      if (nbt != null) {
        nbt.setInteger("charge", (charge - reduce));
        item.setTagCompound(nbt);
      } else {
        NBTTagCompound nbt2 = new NBTTagCompound();
        nbt2.setInteger("charge", (charge - reduce));
        item.setTagCompound(nbt2);
      }
    }

    return reduce;
  }
Ejemplo n.º 25
0
  @Override
  public void modify(ItemStack[] input, ItemStack tool) {
    NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
    int[] keyPair;
    if (tags.hasKey(key)) {
      keyPair = tags.getIntArray(key);
      if (keyPair[0] % max == 0) {
        keyPair[0] += increase;
        keyPair[1] += max;
        tags.setIntArray(key, keyPair);

        int modifiers = tags.getInteger("Modifiers");
        modifiers -= 1;
        tags.setInteger("Modifiers", modifiers);
      } else {
        keyPair[0] += increase;
        tags.setIntArray(key, keyPair);
      }
      updateModTag(tool, keyPair);
    } else {
      int modifiers = tags.getInteger("Modifiers");
      modifiers -= 1;
      tags.setInteger("Modifiers", modifiers);
      String modName = TextHelper.AQUA + "Void Mod (" + increase + "/" + max + ")";
      int tooltipIndex = addToolTip(tool, tooltipName, modName);
      keyPair = new int[] {increase, max, tooltipIndex};
      tags.setIntArray(key, keyPair);
    }
  }
Ejemplo n.º 26
0
  @Override
  public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);

    // nbt.setInteger("MyMoveState", MoveState);
    // nbt.setFloat("MyMovement", MovementTimer);
    // nbt.setInteger("MyButterState", ButterState);
    nbt.setInteger("MyDirection", EntityDirection);
    nbt.setBoolean("CB", canBoil);
    nbt.setInteger("LA", LiquidAmount);
    nbt.setInteger("BA", BoilAmount);

    NBTTagList nbttaglist = new NBTTagList();

    for (int i = 0; i < inv.length; ++i) {
      if (inv[i] != null) {
        NBTTagCompound nbtTagCompound = new NBTTagCompound();
        nbtTagCompound.setByte("Slot", (byte) i);
        inv[i].writeToNBT(nbtTagCompound);
        nbttaglist.appendTag(nbtTagCompound);
      }
    }

    nbt.setTag("Items", nbttaglist);
  }
Ejemplo n.º 27
0
  /** write data to NBTTagCompound from this MapDataBase, similar to Entities and TileEntities */
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    // DEBUG
    System.out.println("MapData.writeToNBT()");

    par1NBTTagCompound.setInteger("dimension", this.dimension);
    par1NBTTagCompound.setInteger("xCenter", this.xCenter);
    par1NBTTagCompound.setInteger("zCenter", this.zCenter);
    par1NBTTagCompound.setByte("scale", this.scale);
    par1NBTTagCompound.setShort("width", (short) 128);
    par1NBTTagCompound.setShort("height", (short) 128);
    par1NBTTagCompound.setByteArray("colors", this.colors);

    // CartoCraft - Save custom icons
    if (this.customIcons.size() > 0) {
      NBTTagList iconTagList = new NBTTagList();
      NBTTagCompound iconTagCompound;
      MapCoord mapcoord;

      for (Iterator iterator = this.customIcons.values().iterator(); iterator.hasNext(); ) {
        mapcoord = (MapCoord) iterator.next();

        iconTagCompound = new NBTTagCompound();
        iconTagCompound.setByte("icon", mapcoord.iconSize);
        iconTagCompound.setByte("xPos", mapcoord.centerX);
        iconTagCompound.setByte("zPos", mapcoord.centerZ);

        iconTagList.appendTag(iconTagCompound);
      }
      par1NBTTagCompound.setTag("customIcons", iconTagList);
    }
  }
Ejemplo n.º 28
0
  @Override
  protected void writeSyncTag(NBTTagCompound NBT) {
    super.writeSyncTag(NBT);

    NBT.setInteger("jam", jam);
    NBT.setInteger("jamc", jamColor);
  }
Ejemplo n.º 29
0
 public ItemStack getItemStackWithData(World world, int x, int y, int z) {
   ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, 0);
   TileEntity tentity = world.getTileEntity(x, y, z);
   if (tentity instanceof TileVendorBlock) {
     TileVendorBlock te = (TileVendorBlock) tentity;
     NBTTagList itemList = new NBTTagList();
     NBTTagCompound tagCompound = new NBTTagCompound();
     for (int i = 0; i < te.getSizeInventory(); i++) {
       ItemStack invStack = te.getStackInSlot(i);
       if (invStack != null) {
         NBTTagCompound tag = new NBTTagCompound();
         tag.setByte("Slot", (byte) i);
         invStack.writeToNBT(tag);
         itemList.appendTag(tag);
       }
     }
     tagCompound.setTag("Inventory", itemList);
     tagCompound.setInteger("CoinSum", te.coinSum);
     tagCompound.setInteger("UserCoinSum", te.userCoinSum);
     tagCompound.setInteger("ItemPrice", te.itemPrice);
     tagCompound.setString("BlockOwner", te.blockOwner);
     tagCompound.setBoolean("Infinite", te.infiniteMode);
     stack.setTagCompound(tagCompound);
     return stack;
   } else return stack;
 }
 public boolean onBlockDestroyed(
     ItemStack par1ItemStack,
     World par2World,
     int par3,
     int par4,
     int par5,
     int par6,
     EntityLivingBase par7EntityLivingBase) {
   if (tool == 4) {
     if (par1ItemStack.getTagCompound() == null) {
       par1ItemStack.setTagCompound(new NBTTagCompound());
     }
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 48) {
       this.currentCharge -= 48;
       tag.setInteger("CurrentCharge", this.currentCharge);
       return true;
     } else return false;
   } else {
     if (par1ItemStack.getTagCompound() == null) {
       par1ItemStack.setTagCompound(new NBTTagCompound());
     }
     NBTTagCompound tag = par1ItemStack.getTagCompound();
     this.currentCharge = tag.getInteger("CurrentCharge");
     if (this.currentCharge >= 24) {
       this.currentCharge -= 24;
       tag.setInteger("CurrentCharge", this.currentCharge);
       return true;
     } else return false;
   }
 }