use of org.spongepowered.api.item.inventory.MultiBlockCarrier in project AdamantineShield by Karanum.
the class PlayerInspectListener method onBlockSecondaryInteract.
@Listener
public void onBlockSecondaryInteract(InteractBlockEvent.Secondary.MainHand e, @First Player p) {
if (!plugin.getInspectManager().isInspector(p))
return;
e.setCancelled(true);
BlockSnapshot block = e.getTargetBlock();
if (!block.getLocation().isPresent())
return;
Location<World> loc = block.getLocation().get();
p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
Runnable task = null;
if (loc.getTileEntity().isPresent()) {
if (loc.getTileEntity().get() instanceof MultiBlockCarrier) {
task = () -> {
MultiBlockCarrier carrier = (MultiBlockCarrier) loc.getTileEntity().get();
plugin.getInspectManager().inspectContainer(p, block.getWorldUniqueId(), carrier.getLocation().getBlockPosition());
};
} else if (loc.getTileEntity().get() instanceof TileEntityCarrier) {
task = () -> plugin.getInspectManager().inspectContainer(p, block.getWorldUniqueId(), loc.getBlockPosition());
}
} else {
task = () -> plugin.getInspectManager().inspect(p, block.getWorldUniqueId(), loc.getBlockPosition().add(e.getTargetSide().asBlockOffset()));
}
if (task != null)
plugin.getThreadPool().execute(task);
}
Aggregations