public TileEntity func_76597_e(int p_76597_1_, int p_76597_2_, int p_76597_3_) {
    ChunkPosition var4 = new ChunkPosition(p_76597_1_, p_76597_2_, p_76597_3_);
    TileEntity var5 = (TileEntity) this.field_76648_i.get(var4);
    if (var5 == null) {
      int var6 = this.func_76610_a(p_76597_1_, p_76597_2_, p_76597_3_);
      if (var6 <= 0 || !Block.field_71973_m[var6].func_71887_s()) {
        return null;
      }

      if (var5 == null) {
        var5 = ((BlockContainer) Block.field_71973_m[var6]).func_72274_a(this.field_76637_e);
        this.field_76637_e.func_72837_a(
            this.field_76635_g * 16 + p_76597_1_,
            p_76597_2_,
            this.field_76647_h * 16 + p_76597_3_,
            var5);
      }

      var5 = (TileEntity) this.field_76648_i.get(var4);
    }

    if (var5 != null && var5.func_70320_p()) {
      this.field_76648_i.remove(var4);
      return null;
    } else {
      return var5;
    }
  }
Esempio n. 2
0
  /** Set the metadata of a block in the chunk */
  public boolean setBlockMetadata(int par1, int par2, int par3, int par4) {
    ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4];

    if (var5 == null) {
      return false;
    } else {
      int var6 = var5.getExtBlockMetadata(par1, par2 & 15, par3);

      if (var6 == par4) {
        return false;
      } else {
        this.isModified = true;
        var5.setExtBlockMetadata(par1, par2 & 15, par3, par4);
        int var7 = var5.getExtBlockID(par1, par2 & 15, par3);

        if (var7 > 0 && Block.blocksList[var7] instanceof ITileEntityProvider) {
          TileEntity var8 = this.getChunkBlockTileEntity(par1, par2, par3);

          if (var8 != null) {
            var8.updateContainingBlockInfo();
            var8.blockMetadata = par4;
          }
        }

        return true;
      }
    }
  }
Esempio n. 3
0
 public boolean func_1010_a(int i, int j, int k, int l, int i1) {
   byte byte0 = (byte) l;
   int j1 = k << 4 | i;
   if (j >= field_35845_c[j1] - 1) {
     field_35845_c[j1] = -999;
   }
   int k1 = field_1533_h[k << 4 | i] & 0xff;
   int l1 =
       field_1539_b[i << field_1537_d.field_35471_b | k << field_1537_d.field_35473_a | j] & 0xff;
   if (l1 == l && field_1536_e.func_771_a(i, j, k) == i1) {
     return false;
   }
   int i2 = field_1531_j * 16 + i;
   int j2 = field_1530_k * 16 + k;
   field_1539_b[i << field_1537_d.field_35471_b | k << field_1537_d.field_35473_a | j] =
       (byte) (byte0 & 0xff);
   if (l1 != 0) {
     if (!field_1537_d.field_1026_y) {
       Block.field_345_n[l1].func_214_b(field_1537_d, i2, j, j2);
     } else if ((Block.field_345_n[l1] instanceof BlockContainer) && l1 != l) {
       field_1537_d.func_692_l(i2, j, j2);
     }
   }
   field_1536_e.func_770_a(i, j, k, i1);
   if (!field_1537_d.field_4209_q.field_6478_e) {
     if (Block.field_341_r[byte0 & 0xff] != 0) {
       if (j >= k1) {
         func_1003_g(i, j + 1, k);
       }
     } else if (j == k1 - 1) {
       func_1003_g(i, j, k);
     }
     field_1537_d.func_616_a(EnumSkyBlock.Sky, i2, j, j2, i2, j, j2);
   }
   field_1537_d.func_616_a(EnumSkyBlock.Block, i2, j, j2, i2, j, j2);
   func_996_c(i, k);
   field_1536_e.func_770_a(i, j, k, i1);
   if (l != 0) {
     if (!field_1537_d.field_1026_y) {
       Block.field_345_n[l].func_235_e(field_1537_d, i2, j, j2);
     }
     if (Block.field_345_n[l] instanceof BlockContainer) {
       TileEntity tileentity = func_1002_d(i, j, k);
       if (tileentity == null) {
         tileentity = ((BlockContainer) Block.field_345_n[l]).func_283_a_();
         field_1537_d.func_654_a(i2, j, j2, tileentity);
       }
       if (tileentity != null) {
         tileentity.func_35144_b();
       }
     }
   } else if (l1 > 0 && (Block.field_345_n[l1] instanceof BlockContainer)) {
     TileEntity tileentity1 = func_1002_d(i, j, k);
     if (tileentity1 != null) {
       tileentity1.func_35144_b();
     }
   }
   field_1526_o = true;
   return true;
 }
Esempio n. 4
0
  /** Gets the TileEntity for a given block in this chunk */
  public TileEntity getChunkBlockTileEntity(int par1, int par2, int par3) {
    ChunkPosition var4 = new ChunkPosition(par1, par2, par3);
    TileEntity var5 = (TileEntity) this.chunkTileEntityMap.get(var4);

    if (var5 == null) {
      int var6 = this.getBlockID(par1, par2, par3);

      if (var6 <= 0 || !Block.blocksList[var6].hasTileEntity()) {
        return null;
      }

      if (var5 == null) {
        var5 = ((ITileEntityProvider) Block.blocksList[var6]).createNewTileEntity(this.worldObj);
        this.worldObj.setBlockTileEntity(
            this.xPosition * 16 + par1, par2, this.zPosition * 16 + par3, var5);
      }

      var5 = (TileEntity) this.chunkTileEntityMap.get(var4);
    }

    if (var5 != null && var5.isInvalid()) {
      this.chunkTileEntityMap.remove(var4);
      return null;
    } else {
      return var5;
    }
  }
Esempio n. 5
0
 public void setNewChunkBlockTileEntity(int i, int j, int k, TileEntity tileentity) {
   ChunkPosition chunkposition = new ChunkPosition(i, j, k);
   tileentity.worldObj = worldObj;
   tileentity.xCoord = xPosition * 16 + i;
   tileentity.yCoord = j;
   tileentity.zCoord = zPosition * 16 + k;
   newChunkTileEntityMap.put(chunkposition, tileentity);
 }
Esempio n. 6
0
 public void func_1023_e(int i, int j, int k) {
   ChunkPosition chunkposition = new ChunkPosition(i, j, k);
   if (field_1538_c) {
     TileEntity tileentity = (TileEntity) field_1529_l.remove(chunkposition);
     if (tileentity != null) {
       tileentity.func_31005_i();
     }
   }
 }
 public void func_76627_f(int p_76627_1_, int p_76627_2_, int p_76627_3_) {
   ChunkPosition var4 = new ChunkPosition(p_76627_1_, p_76627_2_, p_76627_3_);
   if (this.field_76636_d) {
     TileEntity var5 = (TileEntity) this.field_76648_i.remove(var4);
     if (var5 != null) {
       var5.func_70313_j();
     }
   }
 }
Esempio n. 8
0
 public void removeChunkBlockTileEntity(int i, int j, int k) {
   ChunkPosition chunkposition = new ChunkPosition(i, j, k);
   if (isChunkLoaded) {
     TileEntity tileentity = (TileEntity) chunkTileEntityMap.remove(chunkposition);
     if (tileentity != null) {
       tileentity.func_31005_i();
     }
   }
 }
Esempio n. 9
0
  /** Removes the TileEntity for a given block in this chunk */
  public void removeChunkBlockTileEntity(int par1, int par2, int par3) {
    ChunkPosition var4 = new ChunkPosition(par1, par2, par3);

    if (this.isChunkLoaded) {
      TileEntity var5 = (TileEntity) this.chunkTileEntityMap.remove(var4);

      if (var5 != null) {
        var5.invalidate();
      }
    }
  }
Esempio n. 10
0
 public boolean func_1022_a(int i, int j, int k, int l) {
   byte byte0 = (byte) l;
   int i1 = k << 4 | i;
   if (j >= field_35845_c[i1] - 1) {
     field_35845_c[i1] = -999;
   }
   int j1 = field_1533_h[i1] & 0xff;
   int k1 =
       field_1539_b[i << field_1537_d.field_35471_b | k << field_1537_d.field_35473_a | j] & 0xff;
   if (k1 == l) {
     return false;
   }
   int l1 = field_1531_j * 16 + i;
   int i2 = field_1530_k * 16 + k;
   field_1539_b[i << field_1537_d.field_35471_b | k << field_1537_d.field_35473_a | j] =
       (byte) (byte0 & 0xff);
   if (k1 != 0) {
     Block.field_345_n[k1].func_214_b(field_1537_d, l1, j, i2);
   }
   field_1536_e.func_770_a(i, j, k, 0);
   if (Block.field_341_r[byte0 & 0xff] != 0) {
     if (j >= j1) {
       func_1003_g(i, j + 1, k);
     }
   } else if (j == j1 - 1) {
     func_1003_g(i, j, k);
   }
   field_1537_d.func_616_a(EnumSkyBlock.Sky, l1, j, i2, l1, j, i2);
   field_1537_d.func_616_a(EnumSkyBlock.Block, l1, j, i2, l1, j, i2);
   func_996_c(i, k);
   if (l != 0) {
     if (!field_1537_d.field_1026_y) {
       Block.field_345_n[l].func_235_e(field_1537_d, l1, j, i2);
     }
     if (l > 0 && (Block.field_345_n[l] instanceof BlockContainer)) {
       TileEntity tileentity = func_1002_d(i, j, k);
       if (tileentity == null) {
         tileentity = ((BlockContainer) Block.field_345_n[l]).func_283_a_();
         field_1537_d.func_654_a(l1, j, i2, tileentity);
       }
       if (tileentity != null) {
         tileentity.func_35144_b();
       }
     }
   } else if (k1 > 0 && (Block.field_345_n[k1] instanceof BlockContainer)) {
     TileEntity tileentity1 = func_1002_d(i, j, k);
     if (tileentity1 != null) {
       tileentity1.func_35144_b();
     }
   }
   field_1526_o = true;
   return true;
 }
Esempio n. 11
0
  public void onChunkUnload() {
    isChunkLoaded = false;
    TileEntity tileentity;
    for (Iterator iterator = chunkTileEntityMap.values().iterator();
        iterator.hasNext();
        tileentity.func_31005_i()) {
      tileentity = (TileEntity) iterator.next();
    }

    for (int i = 0; i < entities.length; i++) {
      worldObj.func_632_b(entities[i]);
    }
  }
 public void func_76604_a(int p_76604_1_, int p_76604_2_, int p_76604_3_, TileEntity p_76604_4_) {
   ChunkPosition var5 = new ChunkPosition(p_76604_1_, p_76604_2_, p_76604_3_);
   p_76604_4_.func_70308_a(this.field_76637_e);
   p_76604_4_.field_70329_l = this.field_76635_g * 16 + p_76604_1_;
   p_76604_4_.field_70330_m = p_76604_2_;
   p_76604_4_.field_70327_n = this.field_76647_h * 16 + p_76604_3_;
   if (this.func_76610_a(p_76604_1_, p_76604_2_, p_76604_3_) != 0
       && Block.field_71973_m[this.func_76610_a(p_76604_1_, p_76604_2_, p_76604_3_)]
           instanceof BlockContainer) {
     p_76604_4_.func_70312_q();
     this.field_76648_i.put(var5, p_76604_4_);
   }
 }
Esempio n. 13
0
 public void func_1005_a(int i, int j, int k, TileEntity tileentity) {
   ChunkPosition chunkposition = new ChunkPosition(i, j, k);
   tileentity.field_824_e = field_1537_d;
   tileentity.field_823_f = field_1531_j * 16 + i;
   tileentity.field_822_g = j;
   tileentity.field_821_h = field_1530_k * 16 + k;
   if (func_1008_a(i, j, k) == 0
       || !(Block.field_345_n[func_1008_a(i, j, k)] instanceof BlockContainer)) {
     return;
   } else {
     tileentity.func_31004_j();
     field_1529_l.put(chunkposition, tileentity);
     return;
   }
 }
  /**
   * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses
   * this to count ticks and creates a new spawn inside its implementation.
   */
  public void updateEntity() {
    if (this.brewTime > 0) {
      --this.brewTime;

      if (this.brewTime == 0) {
        this.brewPotions();
        this.onInventoryChanged();
      } else if (!this.canBrew()) {
        this.brewTime = 0;
        this.onInventoryChanged();
      } else if (this.ingredientID != this.brewingItemStacks[3].itemID) {
        this.brewTime = 0;
        this.onInventoryChanged();
      }
    } else if (this.canBrew()) {
      this.brewTime = 400;
      this.ingredientID = this.brewingItemStacks[3].itemID;
    }

    int var1 = this.getFilledSlots();

    if (var1 != this.filledSlots) {
      this.filledSlots = var1;
      this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, var1, 2);
    }

    super.updateEntity();
  }
Esempio n. 15
0
 /** Writes a tile entity to NBT. */
 public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
   super.writeToNBT(par1NBTTagCompound);
   par1NBTTagCompound.setShort("typeID", (short) TypeID);
   par1NBTTagCompound.setByte("metaID", MetaID);
   par1NBTTagCompound.setByte("material", material);
   par1NBTTagCompound.setLong("extraData", extraData);
 }
Esempio n. 16
0
 /** Reads a tile entity from NBT. */
 public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readFromNBT(par1NBTTagCompound);
   MetaID = par1NBTTagCompound.getByte("metaID");
   TypeID = par1NBTTagCompound.getShort("typeID");
   material = par1NBTTagCompound.getByte("material");
   extraData = par1NBTTagCompound.getLong("extraData");
 }
Esempio n. 17
0
 public void setChunkBlockTileEntity(int i, int j, int k, TileEntity tileentity) {
   ChunkPosition chunkposition = new ChunkPosition(i, j, k);
   tileentity.worldObj = worldObj;
   tileentity.xCoord = xPosition * 16 + i;
   tileentity.yCoord = j;
   tileentity.zCoord = zPosition * 16 + k;
   if (getBlockID(i, j, k) == 0
       || !(Block.blocksList[getBlockID(i, j, k)] instanceof BlockContainer)) {
     System.out.println("Attempted to place a tile entity where there was no entity tile!");
     return;
   } else {
     tileentity.func_31004_j();
     chunkTileEntityMap.put(chunkposition, tileentity);
     return;
   }
 }
 @Override
 public void updateEntity() {
   super.updateEntity();
   if (this.grindingTicks > 0) { // We have work. This should NOT be 180.
     ++this.grindingTicks;
     if (this.grindingTicks == grindingTicksNeeded) {
       if (this.getStackInSlot(1) == null) {
         this.setInventorySlotContents(1, new ItemStack(modnh.itemFlour, 3));
       } else {
         this.getStackInSlot(1).stackSize += 3;
       }
       this.grindingTicks = 0;
     }
   }
   if (this.grindingTicks == 0) { // We aren't working, or we just finished
     ItemStack stack = this.getStackInSlot(0);
     if (stack == null) return;
     if (stack.itemID == Item.wheat.shiftedIndex) {
       ItemStack out = this.getStackInSlot(1);
       if (out != null) {
         if (out.stackSize + 3 > 64) return;
       }
       this.decrStackSize(0, 1);
       this.grindingTicks = 1;
     }
   }
 }
 /**
  * Returns the TileEntitySpecialRenderer used to render this TileEntity instance, or null if it
  * has no special renderer
  */
 public TileEntitySpecialRenderer getSpecialRendererForEntity(TileEntity par1TileEntity) {
   if (par1TileEntity == null) {
     return null;
   } else {
     return getSpecialRendererForClass(par1TileEntity.getClass());
   }
 }
  public void func_70316_g() {
    if (this.field_70357_b > 0) {
      --this.field_70357_b;
      if (this.field_70357_b == 0) {
        this.func_70353_r();
        this.func_70296_d();
      } else if (!this.func_70350_k()) {
        this.field_70357_b = 0;
        this.func_70296_d();
      } else if (this.field_70356_d != this.field_70359_a[3].field_77993_c) {
        this.field_70357_b = 0;
        this.func_70296_d();
      }
    } else if (this.func_70350_k()) {
      this.field_70357_b = 400;
      this.field_70356_d = this.field_70359_a[3].field_77993_c;
    }

    int var1 = this.func_70351_i();
    if (var1 != this.field_70358_c) {
      this.field_70358_c = var1;
      this.field_70331_k.func_72921_c(
          this.field_70329_l, this.field_70330_m, this.field_70327_n, var1, 2);
    }

    super.func_70316_g();
  }
Esempio n. 21
0
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    this.mobID = par1NBTTagCompound.getString("EntityId");
    this.delay = par1NBTTagCompound.getShort("Delay");

    if (par1NBTTagCompound.hasKey("SpawnData")) {
      this.spawnerTags = par1NBTTagCompound.getCompoundTag("SpawnData");
    } else {
      this.spawnerTags = null;
    }

    if (par1NBTTagCompound.hasKey("MinSpawnDelay")) {
      this.minSpawnDelay = par1NBTTagCompound.getShort("MinSpawnDelay");
      this.maxSpawnDelay = par1NBTTagCompound.getShort("MaxSpawnDelay");
      this.spawnCount = par1NBTTagCompound.getShort("SpawnCount");
    }

    if (par1NBTTagCompound.hasKey("MaxNearbyEntities")) {
      this.field_82350_j = par1NBTTagCompound.getShort("MaxNearbyEntities");
      this.field_82349_r = par1NBTTagCompound.getShort("RequiredPlayerRange");
    }

    if (par1NBTTagCompound.hasKey("SpawnRange")) {
      this.field_82348_s = par1NBTTagCompound.getShort("SpawnRange");
    }
  }
Esempio n. 22
0
  public void importOldChunkTileEntities() {
    File file = wc.downloadSaveHandler.getSaveDirectory();
    if (wc.worldProvider instanceof WorldProviderHell) {
      file = new File(file, "DIM-1");
      file.mkdirs();
    }

    java.io.DataInputStream datainputstream =
        RegionFileCache.getChunkInputStream(file, xPosition, zPosition);
    NBTTagCompound nbttagcompound;
    if (datainputstream != null) {
      try {
        nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream);
      } catch (IOException e) {
        return;
      }
    } else return;

    if (!nbttagcompound.hasKey("Level")) return;

    NBTTagList nbttaglist1 = nbttagcompound.getCompoundTag("Level").getTagList("TileEntities");
    if (nbttaglist1 != null) {
      for (int l = 0; l < nbttaglist1.tagCount(); l++) {
        NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
        TileEntity te = TileEntity.createAndLoadEntity(nbttagcompound2);
        if (te != null) {
          ChunkPosition cp = new ChunkPosition(te.xCoord & 0xf, te.yCoord, te.zCoord & 0xf);
          newChunkTileEntityMap.put(cp, te);
        }
      }
    }
  }
Esempio n. 23
0
  public int func_1004_a(byte abyte0[], int i, int j, int k, int l, int i1, int j1, int k1) {
    for (int l1 = i; l1 < l; l1++) {
      for (int l2 = k; l2 < j1; l2++) {
        int l3 = l1 << field_1537_d.field_35471_b | l2 << field_1537_d.field_35473_a | j;
        int l4 = i1 - j;
        System.arraycopy(abyte0, k1, field_1539_b, l3, l4);
        k1 += l4;
      }
    }

    func_1018_b();
    for (int i2 = i; i2 < l; i2++) {
      for (int i3 = k; i3 < j1; i3++) {
        int i4 = (i2 << field_1537_d.field_35471_b | i3 << field_1537_d.field_35473_a | j) >> 1;
        int i5 = (i1 - j) / 2;
        System.arraycopy(abyte0, k1, field_1536_e.field_1109_a, i4, i5);
        k1 += i5;
      }
    }

    for (int j2 = i; j2 < l; j2++) {
      for (int j3 = k; j3 < j1; j3++) {
        int j4 = (j2 << field_1537_d.field_35471_b | j3 << field_1537_d.field_35473_a | j) >> 1;
        int j5 = (i1 - j) / 2;
        System.arraycopy(abyte0, k1, field_1534_g.field_1109_a, j4, j5);
        k1 += j5;
      }
    }

    for (int k2 = i; k2 < l; k2++) {
      for (int k3 = k; k3 < j1; k3++) {
        int k4 = (k2 << field_1537_d.field_35471_b | k3 << field_1537_d.field_35473_a | j) >> 1;
        int k5 = (i1 - j) / 2;
        System.arraycopy(abyte0, k1, field_1535_f.field_1109_a, k4, k5);
        k1 += k5;
      }
    }

    TileEntity tileentity;
    for (Iterator iterator = field_1529_l.values().iterator();
        iterator.hasNext();
        tileentity.func_35144_b()) {
      tileentity = (TileEntity) iterator.next();
    }

    return k1;
  }
Esempio n. 24
0
  /** Sets the TileEntity for a given block in this chunk */
  public void setChunkBlockTileEntity(int par1, int par2, int par3, TileEntity par4TileEntity) {
    ChunkPosition var5 = new ChunkPosition(par1, par2, par3);
    par4TileEntity.setWorldObj(this.worldObj);
    par4TileEntity.xCoord = this.xPosition * 16 + par1;
    par4TileEntity.yCoord = par2;
    par4TileEntity.zCoord = this.zPosition * 16 + par3;

    if (this.getBlockID(par1, par2, par3) != 0
        && Block.blocksList[this.getBlockID(par1, par2, par3)] instanceof ITileEntityProvider) {
      if (this.chunkTileEntityMap.containsKey(var5)) {
        ((TileEntity) this.chunkTileEntityMap.get(var5)).invalidate();
      }

      par4TileEntity.validate();
      this.chunkTileEntityMap.put(var5, par4TileEntity);
    }
  }
Esempio n. 25
0
 public boolean func_1009_b(int i, int j, int k, int l) {
   field_1526_o = true;
   int i1 = field_1536_e.func_771_a(i, j, k);
   if (i1 == l) {
     return false;
   }
   field_1536_e.func_770_a(i, j, k, l);
   int j1 = func_1008_a(i, j, k);
   if (j1 > 0 && (Block.field_345_n[j1] instanceof BlockContainer)) {
     TileEntity tileentity = func_1002_d(i, j, k);
     if (tileentity != null) {
       tileentity.func_35144_b();
       tileentity.field_35145_n = l;
     }
   }
   return true;
 }
Esempio n. 26
0
 @Override
 public void validate() {
   super.validate();
   bindPipe();
   if (pipe != null) {
     pipe.validate();
   }
 }
Esempio n. 27
0
 @Override
 public void invalidate() {
   initialized = false;
   if (pipe != null) {
     pipe.invalidate();
   }
   super.invalidate();
 }
 private void getTileEntityInfo(TileEntity tileentity) {
   if (tileentity != null) {
     Packet packet = tileentity.getDescriptionPacket();
     if (packet != null) {
       playerNetServerHandler.sendPacket(packet);
     }
   }
 }
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    this.command = par1NBTTagCompound.getString("Command");
    this.succesCount = par1NBTTagCompound.getInteger("SuccessCount");

    if (par1NBTTagCompound.hasKey("CustomName")) {
      this.commandSenderName = par1NBTTagCompound.getString("CustomName");
    }
  }
Esempio n. 30
0
  /** called from onUpdate for all tileEntity in specific chunks */
  private void sendTileEntityToPlayer(TileEntity par1TileEntity) {
    if (par1TileEntity != null) {
      Packet var2 = par1TileEntity.getDescriptionPacket();

      if (var2 != null) {
        this.playerNetServerHandler.sendPacketToPlayer(var2);
      }
    }
  }