@Override
 public final ItemStack getPickBlock(
     MovingObjectPosition target, World world, int x, int y, int z) {
   int meta = world.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
   ChromaTiles m = ChromaTiles.getTileFromIDandMetadata(this, meta);
   ItemStack is =
       this.getHarvestedItemStack(world, target.blockX, target.blockY, target.blockZ, meta, m);
   NBTTagCompound nbt = new NBTTagCompound();
   ((TileEntityAdjacencyUpgrade) world.getTileEntity(target.blockX, target.blockY, target.blockZ))
       .getTagsToWriteToStack(nbt);
   is.stackTagCompound = nbt.hasNoTags() ? null : (NBTTagCompound) nbt.copy();
   return is;
 }
예제 #2
0
  public static boolean setTileEntityNBT(
      World worldIn, BlockPos p_179224_1_, ItemStack p_179224_2_) {
    if (p_179224_2_.hasTagCompound() && p_179224_2_.getTagCompound().hasKey("BlockEntityTag", 10)) {
      TileEntity var3 = worldIn.getTileEntity(p_179224_1_);
      if (var3 != null) {
        NBTTagCompound var4 = new NBTTagCompound();
        NBTTagCompound var5 = (NBTTagCompound) var4.copy();
        var3.writeToNBT(var4);
        NBTTagCompound var6 =
            (NBTTagCompound) p_179224_2_.getTagCompound().getTag("BlockEntityTag");
        var4.merge(var6);
        var4.setInteger("x", p_179224_1_.getX());
        var4.setInteger("y", p_179224_1_.getY());
        var4.setInteger("z", p_179224_1_.getZ());
        if (!var4.equals(var5)) {
          var3.readFromNBT(var4);
          var3.markDirty();
          return true;
        }
      }
    }

    return false;
  }
예제 #3
0
 @Override
 protected void writeEntityToNBT(NBTTagCompound tag) {
   tag.setString(TAG_BLOCK_NAME, getBlockName());
   tag.setInteger(TAG_BLOCK_META, getBlockMeta());
   if (tileEntity != null) tag.setTag(TAG_TILE_ENTITY, tileEntity.copy());
 }