@Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer ep,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    ChromaTiles c = ChromaTiles.getTile(world, x, y, z);
    if (c == ChromaTiles.ROUTERHUB) {
      stack.stackTagCompound = new NBTTagCompound();
      new Coordinate(x, y, z).writeToNBT("target", stack.stackTagCompound);
      return true;
    }

    if (stack.stackTagCompound == null) return false;
    if (Coordinate.readFromNBT("target", stack.stackTagCompound) == null) return false;
    if (!(Coordinate.readFromNBT("target", stack.stackTagCompound).getTileEntity(world)
        instanceof TileEntityRouterHub)) return false;

    return super.onItemUse(stack, ep, world, x, y, z, side, hitX, hitY, hitZ);
  }
 @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;
 }
Ejemplo n.º 3
0
  @Override
  public void harvestBlock(World world, EntityPlayer ep, int x, int y, int z, int meta) {
    ChromaTiles c = ChromaTiles.getTile(world, x, y, z);
    if (c == null) return;
    if (c == ChromaTiles.PYLON) {

    } else {
      boolean silk = EnchantmentHelper.getSilkTouchModifier(ep);
      TileEntity tile = world.getTileEntity(x, y, z);
      if (silk) {
        ItemStack is = c.getCraftedProduct();
        if (tile instanceof TileEntityAccelerator) {
          TileEntityAccelerator te = (TileEntityAccelerator) tile;
          if (is.stackTagCompound == null) is.stackTagCompound = new NBTTagCompound();
          is.stackTagCompound.setInteger("tier", te.getTier());
        }
        ReikaItemHelper.dropItem(world, x + 0.5, y + 0.5, z + 0.5, is);
      } else {
        ReikaItemHelper.dropItems(world, x + 0.5, y + 0.5, z + 0.5, this.getPieces(world, x, y, z));
      }
    }
  }
Ejemplo n.º 4
0
 public ArrayList<ItemStack> getPieces(World world, int x, int y, int z) {
   ArrayList<ItemStack> li = new ArrayList();
   ChromaTiles c = ChromaTiles.getTile(world, x, y, z);
   if (c == null) return li;
   switch (c) {
     case ACCELERATOR:
       for (int i = 0; i < 4; i++) li.add(ChromaStacks.blueShard);
     case GUARDIAN:
       li.add(ChromaStacks.crystalStar);
       break;
     default:
       break;
   }
   return li;
 }
 public ArrayList<TileEntityChromaCrystal> getBoosterCrystals(World world, int x, int y, int z) {
   ArrayList<TileEntityChromaCrystal> li = new ArrayList();
   EntityPlayer owner = null;
   for (Coordinate c : crystalPositions) {
     if (ChromaTiles.getTile(world, x + c.xCoord, y + c.yCoord, z + c.zCoord)
         == ChromaTiles.CRYSTAL) {
       TileEntityChromaCrystal te =
           (TileEntityChromaCrystal) world.getTileEntity(x + c.xCoord, y + c.yCoord, z + c.zCoord);
       {
         EntityPlayer ep = te.getPlacer();
         if (ep != null && (owner == null || ep == owner)) {
           if (owner == null) owner = ep;
           li.add(te);
         }
       }
     }
   }
   return li;
 }