Exemplo n.º 1
0
 public void mergeWith(EntityLootBall other) {
   if (other == this) {
     return;
   }
   other.setDead();
   items.addAll(Lists.newArrayList(other.getItemList()));
   other.getItemList().clear();
   ItemHelper.compactItemList(items);
 }
Exemplo n.º 2
0
  public EntityLootBall(World world, List<ItemStack> drops, double x, double y, double z) {
    super(world);
    items = drops;

    this.setSize(0.25F, 0.25F);
    this.yOffset = this.height / 2.0F;
    this.setPosition(x, y, z);
    this.motionX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
    this.motionY = 0.20000000298023224D;
    this.motionZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
    ItemHelper.compactItemList(items);
  }
Exemplo n.º 3
0
  @Override
  public void onCollideWithPlayer(EntityPlayer player) {
    if (this.worldObj.isRemote) {
      return;
    }

    boolean playSound = false;
    List<ItemStack> list = Lists.newArrayList();

    if (player.openContainer instanceof AlchBagContainer) {
      IInventory inv = ((AlchBagContainer) player.openContainer).inventory;

      if (ItemHelper.invContainsItem(inv, new ItemStack(ObjHandler.blackHole, 1, 1))) {
        for (ItemStack stack : items) {
          ItemStack remain = ItemHelper.pushStackInInv(inv, stack);

          if (remain == null) {
            if (!playSound) {
              playSound = true;
            }

            continue;
          } else {
            remain = ItemHelper.pushStackInInv(player.inventory, remain);

            if (remain == null) {
              if (!playSound) {
                playSound = true;
              }

              continue;
            } else {
              list.add(remain);
            }

            if (!playSound && !ItemHelper.areItemStacksEqual(stack, remain)) {
              playSound = true;
            }
          }
        }

        if (playSound) {
          this.worldObj.playSoundAtEntity(
              player,
              "random.pop",
              0.2F,
              ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
        }

        if (list.size() > 0) {
          items = list;
        } else {
          this.setDead();
        }

        return;
      }
    } else {
      ItemStack bag =
          AlchemicalBag.getFirstBagWithSuctionItem(player, player.inventory.mainInventory);

      if (bag != null) {
        ItemStack[] inv = AlchemicalBags.get(player, (byte) bag.getItemDamage());

        for (ItemStack stack : items) {
          ItemStack remain = ItemHelper.pushStackInInv(inv, stack);

          if (remain == null) {
            if (!playSound) {
              playSound = true;
            }

            continue;
          } else {
            remain = ItemHelper.pushStackInInv(player.inventory, remain);

            if (remain == null) {
              if (!playSound) {
                playSound = true;
              }

              continue;
            } else {
              list.add(remain);
            }

            if (!playSound && !ItemHelper.areItemStacksEqual(stack, remain)) {
              playSound = true;
            }
          }
        }

        if (playSound) {
          AlchemicalBags.set(player, (byte) bag.getItemDamage(), inv);
          AlchemicalBags.syncPartial(player, bag.getItemDamage());
        }
      } else {
        for (ItemStack stack : items) {
          ItemStack remaining = ItemHelper.pushStackInInv(player.inventory, stack);

          if (remaining == null) {
            if (!playSound) {
              playSound = true;
            }

            continue;
          } else {
            list.add(remaining);
          }

          if (!playSound && !ItemHelper.areItemStacksEqual(stack, remaining)) {
            playSound = true;
          }
        }
      }

      if (playSound) {
        this.worldObj.playSoundAtEntity(
            player,
            "random.pop",
            0.2F,
            ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
      }

      if (list.size() > 0) {
        items = list;
      } else {
        this.setDead();
      }
    }
  }