use of gregtech.common.items.behaviors.ClipboardBehavior in project GregTech by GregTechCEu.
the class MetaTileEntityClipboard method createUI.
@Override
public ModularUI createUI(EntityPlayer entityPlayer) {
if (getClipboard().isItemEqual(CLIPBOARD.getStackForm())) {
List<IItemBehaviour> behaviours = ((MetaItem<?>) getClipboard().getItem()).getBehaviours(getClipboard());
Optional<IItemBehaviour> clipboardBehaviour = behaviours.stream().filter((x) -> x instanceof ClipboardBehavior).findFirst();
if (!clipboardBehaviour.isPresent())
return null;
if (clipboardBehaviour.get() instanceof ClipboardBehavior) {
// We can't have this actually set the player's hand
PlayerInventoryHolder holder = new PlayerInventoryHolder(new GregFakePlayer(entityPlayer.world), EnumHand.MAIN_HAND);
holder.setCustomValidityCheck(this::isValid).setCurrentItem(this.getClipboard());
if (entityPlayer instanceof GregFakePlayer) {
// This is how to tell if this is being called in-world or not
return ((ClipboardBehavior) clipboardBehaviour.get()).createMTEUI(holder, entityPlayer);
} else {
return ((ClipboardBehavior) clipboardBehaviour.get()).createUI(holder, entityPlayer);
}
}
}
return null;
}
Aggregations