use of mekanism.common.item.ItemConfigurator in project Mekanism by mekanism.
the class TileEntityMekanism method openGui.
public ActionResultType openGui(PlayerEntity player) {
// Everything that calls this has isRemote being false but add the check just in case anyways
if (hasGui() && !isRemote() && !player.isShiftKeyDown()) {
if (hasSecurity() && !SecurityUtils.canAccess(player, this)) {
SecurityUtils.displayNoAccess(player);
return ActionResultType.FAIL;
}
// Pass on this activation if the player is rotating with a configurator
ItemStack stack = player.getMainHandItem();
if (isDirectional() && !stack.isEmpty() && stack.getItem() instanceof ItemConfigurator) {
ItemConfigurator configurator = (ItemConfigurator) stack.getItem();
if (configurator.getMode(stack) == ItemConfigurator.ConfiguratorMode.ROTATE) {
return ActionResultType.PASS;
}
}
// Pass on this activation if the player is using a configuration card (and this tile supports the capability)
if (getCapability(Capabilities.CONFIG_CARD_CAPABILITY, null).isPresent()) {
if (!stack.isEmpty() && stack.getItem() instanceof ItemConfigurationCard) {
return ActionResultType.PASS;
}
}
NetworkHooks.openGui((ServerPlayerEntity) player, Attribute.get(getBlockType(), AttributeGui.class).getProvider(this), worldPosition);
return ActionResultType.SUCCESS;
}
return ActionResultType.PASS;
}
Aggregations