Examples of BeforeItemRemovedFromInventory


Examples of org.terasology.logic.inventory.events.BeforeItemRemovedFromInventory

        // Validate the move
        EntityRef itemFrom = InventoryUtils.getItemAt(from, slotFrom);
        EntityRef itemTo = InventoryUtils.getItemAt(to, slotTo);

        if (itemFrom.exists()) {
            BeforeItemRemovedFromInventory removeFrom = new BeforeItemRemovedFromInventory(instigator, itemFrom, slotFrom);
            from.send(removeFrom);
            if (removeFrom.isConsumed()) {
                return false;
            }
        }

        if (itemTo.exists()) {
            BeforeItemRemovedFromInventory removeTo = new BeforeItemRemovedFromInventory(instigator, itemTo, slotTo);
            to.send(removeTo);
            if (removeTo.isConsumed()) {
                return false;
            }
        }

        if (itemTo.exists()) {
View Full Code Here

Examples of org.terasology.logic.inventory.events.BeforeItemRemovedFromInventory

        }
        if (countOnTo + amount > itemFrom.maxStackSize) {
            return false;
        }

        BeforeItemRemovedFromInventory removeFrom = new BeforeItemRemovedFromInventory(instigator, InventoryUtils.getItemAt(from, slotFrom), slotFrom);
        from.send(removeFrom);
        if (removeFrom.isConsumed()) {
            return false;
        }

        if (itemTo == null) {
            BeforeItemPutInInventory putTo = new BeforeItemPutInInventory(instigator, InventoryUtils.getItemAt(from, slotFrom), slotTo);
View Full Code Here

Examples of org.terasology.logic.inventory.events.BeforeItemRemovedFromInventory

    }


    static boolean moveItemToSlots(EntityRef instigator, EntityRef from, int fromSlot, EntityRef to, List<Integer> toSlots) {
        EntityRef fromItem = InventoryUtils.getItemAt(from, fromSlot);
        BeforeItemRemovedFromInventory removeFrom = new BeforeItemRemovedFromInventory(instigator, fromItem, fromSlot);
        from.send(removeFrom);
        if (removeFrom.isConsumed()) {
            return false;
        }

        boolean movedToStack = moveToExistingStacksInSlots(from, fromSlot, to, toSlots);
View Full Code Here

Examples of org.terasology.logic.inventory.events.BeforeItemRemovedFromInventory

        Mockito.when(inventory.send(Matchers.any(BeforeItemRemovedFromInventory.class))).then(
                new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Exception {
                        BeforeItemRemovedFromInventory event = (BeforeItemRemovedFromInventory) invocation.getArguments()[0];
                        event.consume();
                        return null;
                    }
                }
        );
View Full Code Here

Examples of org.terasology.logic.inventory.events.BeforeItemRemovedFromInventory

                new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Exception {
                        Object arg = invocation.getArguments()[0];
                        if (arg instanceof BeforeItemRemovedFromInventory) {
                            BeforeItemRemovedFromInventory event = (BeforeItemRemovedFromInventory) arg;
                            if (event.getSlot() == 1) {
                                event.consume();
                            }
                        }
                        return null;
                    }
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.