Fix Scripted Item Crash

This commit is contained in:
Kam committed 2025-03-08 17:52:39 -05:00
1 parent 299d3f3bcc
commit b43d8d9065
1 file changed
+10 -5
@@ -1,12 +1,15 @@
package noppes.npcs.items;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumGuiType;
@@ -21,11 +24,13 @@ public class ItemScripted extends ItemCustomizable {
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if(player.isSneaking() && player.capabilities.isCreativeMode) {
if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
} else {
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, player);
if (!world.isRemote){
if(player.isSneaking() && player.capabilities.isCreativeMode) {
if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){
ChatAlertPacket.sendChatAlert((EntityPlayerMP) player, "availability.permission");
} else {
NoppesUtilServer.sendOpenGui(player, EnumGuiType.ScriptItem, null, 0, 0, 0);
}
}
}
return super.onItemRightClick(stack, world, player);