Search in sources :

Example 1 with LanternBlockCarrier

use of org.lanternpowered.server.inventory.carrier.LanternBlockCarrier in project LanternServer by LanternPowered.

the class CraftingTableInteractionBehavior method tryInteract.

@Override
public BehaviorResult tryInteract(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    final Optional<Player> optPlayer = context.getContext(ContextKeys.PLAYER);
    if (optPlayer.isPresent()) {
        final CraftingTableInventory craftingTableInventory = VanillaInventoryArchetypes.CRAFTING_TABLE.builder().withCarrier(new LanternBlockCarrier(context.requireContext(ContextKeys.BLOCK_LOCATION))).build(Lantern.getMinecraftPlugin());
        final Optional<Container> optContainer = optPlayer.get().openInventory(craftingTableInventory);
        if (optContainer.isPresent()) {
            return BehaviorResult.SUCCESS;
        }
    }
    return BehaviorResult.PASS;
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) CraftingTableInventory(org.lanternpowered.server.inventory.vanilla.block.CraftingTableInventory) Container(org.spongepowered.api.item.inventory.Container) LanternBlockCarrier(org.lanternpowered.server.inventory.carrier.LanternBlockCarrier)

Aggregations

LanternBlockCarrier (org.lanternpowered.server.inventory.carrier.LanternBlockCarrier)1 CraftingTableInventory (org.lanternpowered.server.inventory.vanilla.block.CraftingTableInventory)1 Player (org.spongepowered.api.entity.living.player.Player)1 Container (org.spongepowered.api.item.inventory.Container)1