Still looking for some assistance. New to hyperion.
|
Seem to cannot fix this issue. Using 459 hyperion base, has anyone seemed to find the solution to this? I can post methods of where its called.
Still looking for some assistance. New to hyperion.
I would iterate through your list of ground items to check if there's an existing arrow on that tile. If so just update the count by 1.
what exactly do you need help with? explain in-depth please
Basically, when an arrow is shot, it does a simple check to see if the current ground item is stackable. If so, it then checks to see if it exists. Afterwards, it will increase the count, remove the old ground item then replace it with the new item. Right now, the arrows (in this case yes) drop 2 at a time and still trying to resolve this issue.
Heres the code I wrote up and isnt fully working yet. This is my issue here.
Code:public void addGroundItem(GroundItem item, boolean showToAll, Player player) { player.getActionSender().sendCreateGroundItem(item); Region region = World.getWorld().getRegionManager().getRegionByLocation(item.getLocation()); region.addGroundItem(item); if (item.getItem().getDefinition().isStackable()) { if(groundItemExists(item.getLocation(), item)) { item.getItem().increaseCount(item.getItem().getCount()); player.getActionSender().sendDestroyGroundItem(item); player.getActionSender().sendCreateGroundItem(item); return; } } if (showToAll) { World.getWorld().submit(new GroundItemEvent(item, Function.SHOW)); } World.getWorld().submit(new GroundItemEvent(item, Function.REMOVE)); }
Here's something that looks like it will work, but still is not stacking the arrows on top of each other. Anyone have some input?
Code:public void addGroundItem(GroundItem item, boolean showToAll, Player player) { player.getActionSender().sendCreateGroundItem(item); Region region = World.getWorld().getRegionManager().getRegionByLocation(item.getLocation()); region.addGroundItem(item); if (item.getItem().getDefinition().isStackable()) { for(GroundItem gI : region.getGroundItems()) { if (gI.getLocation().equals(item.getLocation()) && gI.getItem().getId() == item.getItem().getId()) { gI.getItem().increaseCount(gI.getItem().getCount() + item.getItem().getCount()); player.getActionSender().sendDestroyGroundItem(item); player.getActionSender().sendCreateGroundItem(item); break; } } } if (showToAll) { World.getWorld().submit(new GroundItemEvent(item, Function.SHOW)); } World.getWorld().submit(new GroundItemEvent(item, Function.REMOVE)); }
Still having this issue.
i actually did this for my combat base yesterday and got it working fine, I'll post the code once I'm home
Code:/** * Registers a new ground item and stacks it on top of any existing ground * items with the same id. * * @param registerable * the ground item to register and stack if applicable. */ public void registerAndStack(GroundItem registerable) { int itemCount = 0; for (Iterator<GroundItem> iterator = itemList.iterator(); iterator.hasNext();) { GroundItem item = iterator.next(); if (item == null) { continue; } if (item.getItem().getId() == registerable.getItem().getId() && item.getPosition().equals(registerable.getPosition()) && item.getPlayer().getUsername().equals(registerable.getPlayer().getUsername())) { itemCount += item.getItem().getAmount(); item.fireOnUnregister(); iterator.remove(); } } registerable.getItem().incrementAmountBy(itemCount); /** Fire the item's registration event. */ registerable.fireOnRegister(); /** Add the item in the database. */ itemList.add(registerable); }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |