private DroneAICC getTargetAI() throws Exception {
   if (drone != null && drone.getRunningTargetAI() instanceof DroneAICC) {
     return (DroneAICC) drone.getRunningTargetAI();
   } else {
     setDrone(
         null); // set to null in case of the drone is connected, but for some reason isn't
                // currently running the piece (shouldn't be possible).
     throw new IllegalStateException("There's no connected Drone!");
   }
 }
 private DroneAICC getAI() throws Exception {
   if (drone != null) {
     for (EntityAITaskEntry task : drone.getRunningTasks()) {
       if (task.action instanceof DroneAICC) return (DroneAICC) task.action;
     }
   }
   setDrone(
       null); // set to null in case of the drone is connected, but for some reason isn't currently
              // running the piece (shouldn't be possible).
   throw new IllegalStateException("There's no connected Drone!");
 }
Пример #3
0
  @Override
  public void handleGUIButtonPress(int guiID, EntityPlayer player) {
    super.handleGUIButtonPress(guiID, player);
    if (guiID == 1) {
      for (int i = 0; i < shoppingItems.length; i++) {
        if (shoppingItems[i] >= 0) {
          AmadronOffer offer = offers.get(shoppingItems[i]);
          if (offer.getInput() instanceof ItemStack) {
            ItemStack queryingItems = (ItemStack) offer.getInput();
            int amount = queryingItems.stackSize * shoppingAmounts[i];
            List<ItemStack> stacks = new ArrayList<ItemStack>();
            while (amount > 0) {
              ItemStack stack = queryingItems.copy();
              stack.stackSize = Math.min(amount, stack.getMaxStackSize());
              stacks.add(stack);
              amount -= stack.stackSize;
            }
            ChunkPosition pos =
                ItemAmadronTablet.getItemProvidingLocation(player.getCurrentEquippedItem());
            World world = null;
            if (pos == null) {
              pos = new ChunkPosition((int) player.posX, (int) player.posY, (int) player.posZ);
              world = player.worldObj;
            } else {
              world =
                  ItemAmadronTablet.getWorldForDimension(
                      ItemAmadronTablet.getItemProvidingDimension(player.getCurrentEquippedItem()));
            }
            EntityDrone drone =
                (EntityDrone)
                    PneumaticRegistry.getInstance()
                        .retrieveItemsAmazonStyle(
                            world,
                            pos.chunkPosX,
                            pos.chunkPosY,
                            pos.chunkPosZ,
                            stacks.toArray(new ItemStack[stacks.size()]));
            drone.setHandlingOffer(offer, shoppingAmounts[i], player.getCurrentEquippedItem());
          } else {
            FluidStack queryingFluid = ((FluidStack) offer.getInput()).copy();
            queryingFluid.amount *= shoppingAmounts[i];

            ChunkPosition pos =
                ItemAmadronTablet.getLiquidProvidingLocation(player.getCurrentEquippedItem());
            if (pos != null) {
              World world =
                  ItemAmadronTablet.getWorldForDimension(
                      ItemAmadronTablet.getLiquidProvidingDimension(
                          player.getCurrentEquippedItem()));
              EntityDrone drone =
                  (EntityDrone)
                      PneumaticRegistry.getInstance()
                          .retrieveFluidAmazonStyle(
                              world, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, queryingFluid);
              drone.setHandlingOffer(offer, shoppingAmounts[i], player.getCurrentEquippedItem());
            }
          }
        }
      }
      Arrays.fill(shoppingAmounts, 0);
      Arrays.fill(shoppingItems, -1);
    } else if (guiID == 2) {
      player.openGui(
          PneumaticCraft.instance,
          CommonProxy.EnumGuiId.AMADRON_ADD_TRADE.ordinal(),
          player.worldObj,
          0,
          0,
          0);
    }
  }
 @Override
 public Packet getDescriptionPacket() {
   NBTTagCompound tag = new NBTTagCompound();
   tag.setInteger("drone", drone != null ? drone.getEntityId() : -1);
   return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag);
 }