Solved how could I prevent autostacking?

Discussion in 'Plugin Development' started by xize, Jul 31, 2014.

Thread Status:
Not open for further replies.
  1. Offline



    so I got a little trouble and I also probably know what is causing it but I need to know how to stop auto stacking so it would not change the Item entity object.

    for now I do something like this, and I know this is also the reason why you shouldn't store objects like this way:p:

        public void onBleed(EntityDamageEvent e) {
            LinkedHashMap<Location, Item> hash = new LinkedHashMap<Location, Item>();
            for(int i = 0; i < e.getDamage()*3; i++) {
                Location loc = e.getEntity().getLocation();
                int x = rand.nextInt(range);
                int z = rand.nextInt(range);
                Location newloc = loc.add(x, 5, z);
                Item item = newloc.getWorld().dropItemNaturally(newloc, new ItemStack(Material.WOOL, 64, DyeColor.RED.getWoolData()));
                item.setMetadata("bleed", new FixedMetadataValue(xEssentials.getPlugin(), UUID.randomUUID()));
                Location loca = newloc.getWorld().getHighestBlockAt(newloc).getRelative(BlockFace.DOWN).getLocation();
                for(Entity entity : e.getEntity().getNearbyEntities(14, 120, 14)) {
                    if(entity instanceof Player) {
                        Player p = (Player) entity;
                        p.sendBlockChange(loca, Material.WOOL, DyeColor.RED.getWoolData());
                hash.put(loca, item);
            BleedRegen regen = new BleedRegen(hash);
    but since it autostacks, the value in the LinkedHashMap does not work with Item.remove(); because the object has been changed to something else probably due the autostacking.

    how would I go about to stop this?



    got it working, I just mentoided for some reason it does delete the ones in the LinkedHashMap but there are doubled/cloned stacks so to fix that I just looped through entities in the world and checked the custom metadata and from there removing the item that worked fine:)
Thread Status:
Not open for further replies.

Share This Page