@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (CoreUtils.isFakePlayer(player) || hand != EnumHand.MAIN_HAND) {
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
if (needsTag(stack)) {
setDefaultInventoryTag(stack);
}
if (ServerHelper.isServerWorld(world)) {
if (SecurityHelper.isSecure(stack) && SecurityHelper.isDefaultUUID(SecurityHelper.getOwner(stack).getId())) {
SecurityHelper.setOwner(stack, player.getGameProfile());
ChatHelper.sendIndexedChatMessageToPlayer(player, new TextComponentTranslation("chat.cofh.secure.item.success"));
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
if (canPlayerAccess(stack, player)) {
if (player.isSneaking() && ItemHelper.getItemDamage(stack) != CREATIVE) {
player.openGui(ThermalExpansion.instance, GuiHandler.SATCHEL_FILTER_ID, world, 0, 0, 0);
} else {
player.openGui(ThermalExpansion.instance, GuiHandler.SATCHEL_ID, world, 0, 0, 0);
}
} else if (SecurityHelper.isSecure(stack)) {
ChatHelper.sendIndexedChatMessageToPlayer(player, new TextComponentTranslation("chat.cofh.secure.warning", SecurityHelper.getOwnerName(stack)));
return new ActionResult<>(EnumActionResult.FAIL, stack);
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}