Exemplo n.º 1
0
 @Override
 public void writeToNBT(NBTTagCompound nbt) {
   // System.out.printf("SGRingTE.writeToNBT\n");
   super.writeToNBT(nbt);
   nbt.setBoolean("isMerged", isMerged);
   nbt.setInteger("baseX", baseX);
   nbt.setInteger("baseY", baseY);
   nbt.setInteger("baseZ", baseZ);
 }
Exemplo n.º 2
0
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   // System.out.printf("SGRingTE.readFromNBT\n");
   super.readFromNBT(nbt);
   isMerged = nbt.getBoolean("isMerged");
   baseX = nbt.getInteger("baseX");
   baseY = nbt.getInteger("baseY");
   baseZ = nbt.getInteger("baseZ");
 }
  @Override
  public void updateEntity() {
    if (this.worldObj.isRemote) {
      this.rot += 0.1F;
      if (this.rot >= 360F) this.rot -= 360F;
    }

    super.updateEntity();
  }
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    // System.out.println("read: "+this.worldObj.isRemote);

    super.readFromNBT(nbt);

    this.inventory = new ItemStack[this.getSizeInventory() + 2];
    NBTTagList nbtlist = nbt.getTagList("Items", 10);

    for (int i = 0; i < nbtlist.tagCount(); i++) {
      NBTTagCompound nbtslot = (NBTTagCompound) nbtlist.getCompoundTagAt(i);
      int j = nbtslot.getByte("Slot") & 255;

      if ((j >= 0) && (j < this.getSizeInventory() + 2))
        this.inventory[j] = ItemStack.loadItemStackFromNBT(nbtslot);
    }
    this.showNum = nbt.getBoolean("showNum");
  }
  @Override
  public void writeToNBT(NBTTagCompound nbt) {
    // System.out.println("write: "+this.worldObj.isRemote);

    super.writeToNBT(nbt);

    NBTTagList nbtlist = new NBTTagList();

    for (int i = 0; i < this.getSizeInventory() + 2; i++) {
      if (this.inventory[i] != null) {
        NBTTagCompound nbtslot = new NBTTagCompound();
        nbtslot.setByte("Slot", (byte) i);
        this.inventory[i].writeToNBT(nbtslot);
        nbtlist.appendTag(nbtslot);
      }
    }

    nbt.setTag("Items", nbtlist);
    nbt.setBoolean("showNum", this.showNum);
  }
  @Override
  public void onInventoryChanged() {
    super.onInventoryChanged();

    if (!this.worldObj.isRemote) {
      this.rotateCraftingGrid();

      this.inventory[this.getSizeInventory()] =
          CraftingManager.getInstance()
              .findMatchingRecipe(this.container.craftMatrix, this.worldObj);

      if (CraftingPillars.modThaumcraft) {
        if (this.worldObj.loadedEntityList != null) {
          float closest = Float.MAX_VALUE;
          for (int i = 0; i < this.worldObj.loadedEntityList.size(); i++) {
            if (this.worldObj.loadedEntityList.get(i) instanceof EntityPlayer) {
              EntityPlayer currentPlayer = (EntityPlayer) this.worldObj.loadedEntityList.get(i);
              if (currentPlayer.isEntityAlive()) {
                float distance =
                    (float) currentPlayer.getDistanceSq(this.xCoord, this.yCoord, this.zCoord);
                if (distance < closest) {
                  closest = distance;
                  this.closestPlayer = currentPlayer;
                }
              }
            }
          }
        }

        //				if(this.closestPlayer != null && this.getStackInSlot(10) != null)
        //				{
        //					ItemStack result =
        // CraftingPillarsAPIHelper.findMatchingArcaneRecipe(this.container.craftMatrix,
        // this.closestPlayer);
        //					if(result != null)
        //					{
        //						FMLLog.warning("Result " + result.getDisplayName());
        //
        //						this.inventory[this.getSizeInventory()] = result;
        //						aspectsForRecipe =
        // CraftingPillarsAPIHelper.findMatchingArcaneRecipeAspects(this.container.craftMatrix,
        // this.closestPlayer);
        //
        //						for(int i = 0; i < aspectsForRecipe.size(); i++)
        //						{
        //							FMLLog.warning(aspectsForRecipe.getAspects()[i].getName() + ": " +
        // aspectsForRecipe.getAmount(aspectsForRecipe.getAspects()[i]));
        //						}
        //
        //					}
        //					else {
        //						FMLLog.warning("no Result");
        //
        ////						aspects = null;
        //					}
        //				}

      }
      CraftingPillars.proxy.sendToPlayers(
          this.getDescriptionPacket(), this.worldObj, this.xCoord, this.yCoord, this.zCoord, 64);
    }
  }