Magic Book Item + Magic Player Packets

This commit is contained in:
Kam committed 2025-03-14 20:32:26 -04:00
1 parent 62046b10e6
commit 3e10207b41
19 files changed
+466 -18

No files matched your search

@@ -20,6 +20,9 @@ import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiUnfocusedPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomScrollClickPacket;
import kamkeel.npcs.network.packets.player.item.GuiMagicBookPacket;
import kamkeel.npcs.network.packets.player.item.GuiPaintbrushPacket;
import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket;
import kamkeel.npcs.network.packets.player.profile.*;
import kamkeel.npcs.network.packets.request.*;
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
@@ -429,6 +432,11 @@ public class PacketHandler {
PLAYER_PACKET.registerPacket(new CustomGuiUnfocusedPacket());
PLAYER_PACKET.registerPacket(new CustomScrollClickPacket());
// Item Gui Packets
PLAYER_PACKET.registerPacket(new GuiPaintbrushPacket());
PLAYER_PACKET.registerPacket(new GuiMagicBookPacket());
PLAYER_PACKET.registerPacket(new MagicCyclesPacket());
// Profile Packets
PLAYER_PACKET.registerPacket(new ProfileCreatePacket());
PLAYER_PACKET.registerPacket(new ProfileRemovePacket());
@@ -95,7 +95,14 @@ public class PacketUtil {
break;
case HAMMER:
if (item.getItem() != CustomItems.tool || item.getItemDamage() != 0) {
LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Pather, they could be a hacker",
LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Hammer, they could be a hacker",
player.getCommandSenderName(), type));
return false;
}
break;
case MAGIC_BOOK:
if (item.getItem() != CustomItems.tool || item.getItemDamage() != 2) {
LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Magic Book, they could be a hacker",
player.getCommandSenderName(), type));
return false;
}
@@ -158,6 +165,8 @@ public class PacketUtil {
return item.getItem() == CustomItems.tool && item.getItemDamage() == 1;
case HAMMER:
return item.getItem() == CustomItems.tool && item.getItemDamage() == 0;
case MAGIC_BOOK:
return item.getItem() == CustomItems.tool && item.getItemDamage() == 2;
default:
return false;
}
@@ -197,6 +206,8 @@ public class PacketUtil {
return "Paintbrush";
case HAMMER:
return "Hammer";
case MAGIC_BOOK:
return "Magic Book";
default:
return type.toString();
}
@@ -9,5 +9,6 @@ public enum EnumItemPacketType {
PATHER,
BLOCK,
BRUSH,
HAMMER
HAMMER,
MAGIC_BOOK
}
@@ -1,5 +1,7 @@
package kamkeel.npcs.network.enums;
import noppes.npcs.client.gui.custom.components.CustomGuiButton;
public enum EnumPlayerPacket {
FollowerAction,
Transport,
@@ -14,12 +16,16 @@ public enum EnumPlayerPacket {
GetRole,
InputDevice,
ScreenSize,
MagicCycles,
CustomGuiButton,
CustomGuiScrollClick,
CustomGuiClose,
CustomGuiUnfocused,
GuiPaintbrush,
GuiMagicBook,
ProfileCreate,
ProfileRemove,
ProfileRename,
@@ -0,0 +1,66 @@
package kamkeel.npcs.network.packets.player.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumGuiType;
import java.io.IOException;
public class GuiMagicBookPacket extends AbstractPacket {
public static String packetName = "Player|GuiMagicBook";
private int guiIndex, posX, posY, posZ;
public GuiMagicBookPacket(int guiIndex, int posX, int posY, int posZ) {
this.guiIndex = guiIndex;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
public GuiMagicBookPacket() {}
@Override
public Enum getType() {
return EnumPlayerPacket.GuiMagicBook;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.PLAYER_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(guiIndex);
out.writeInt(posX);
out.writeInt(posY);
out.writeInt(posZ);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.MAGIC_BOOK))
return;
int index = in.readInt();
int x = in.readInt();
int y = in.readInt();
int z = in.readInt();
EnumGuiType gui = EnumGuiType.values()[index];
NoppesUtilServer.sendOpenGui(player, gui, null, x, y, z);
}
}
@@ -0,0 +1,67 @@
package kamkeel.npcs.network.packets.player.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumGuiType;
import java.io.IOException;
public class GuiPaintbrushPacket extends AbstractPacket {
public static String packetName = "Player|GuiPaintbrush";
private int guiIndex, posX, posY, posZ;
public GuiPaintbrushPacket(int guiIndex, int posX, int posY, int posZ) {
this.guiIndex = guiIndex;
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
public GuiPaintbrushPacket() {}
@Override
public Enum getType() {
return EnumPlayerPacket.GuiPaintbrush;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.PLAYER_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(guiIndex);
out.writeInt(posX);
out.writeInt(posY);
out.writeInt(posZ);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.BRUSH))
return;
int index = in.readInt();
int x = in.readInt();
int y = in.readInt();
int z = in.readInt();
EnumGuiType gui = EnumGuiType.values()[index];
NoppesUtilServer.sendOpenGui(player, gui, null, x, y, z);
}
}
@@ -0,0 +1,85 @@
package kamkeel.npcs.network.packets.player.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.*;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import kamkeel.npcs.network.packets.request.magic.MagicGetPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.MagicCycle;
import java.io.IOException;
import java.util.HashMap;
import static kamkeel.npcs.network.packets.data.large.ScrollDataPacket.sendScrollData;
public class MagicCyclesPacket extends AbstractPacket {
public static String packetName = "Player|MagicCycles";
private int id;
public MagicCyclesPacket() {}
public MagicCyclesPacket(int id) {
this.id = id;
}
@Override
public Enum getType() {
return EnumPlayerPacket.MagicCycles;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.PLAYER_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.id);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.MAGIC_BOOK))
return;
int id = in.readInt();
if(id == -1){
HashMap<String, Integer> map = new HashMap<>();
for (MagicCycle magicCycle : MagicController.getInstance().cycles.values()) {
map.put(magicCycle.displayName.replace("&", "\u00A7"), magicCycle.id);
}
sendScrollData((EntityPlayerMP) player, map, EnumScrollData.MAGIC_CYCLES);
} else {
MagicCycle cycle = MagicController.getInstance().getCycle(id);
if(cycle == null)
return;
NBTTagCompound compound = new NBTTagCompound();
NBTTagCompound magicCompound = new NBTTagCompound();
cycle.writeNBT(magicCompound);
compound.setTag("MagicCycle", magicCompound);
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
public static void GetAll() {
PacketClient.sendClient(new MagicCyclesPacket(-1));
}
public static void GetCycle(int id) {
PacketClient.sendClient(new MagicCyclesPacket(id));
}
}
@@ -54,7 +54,7 @@ public final class GuiRequestPacket extends AbstractPacket {
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER, EnumItemPacketType.BRUSH))
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER, EnumItemPacketType.BRUSH, EnumItemPacketType.MAGIC_BOOK))
return;
int index = in.readInt();
int x = in.readInt();
@@ -52,7 +52,7 @@ public final class MagicGetPacket extends AbstractPacket {
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND))
return;
Action action = Action.values()[in.readInt()];
@@ -41,7 +41,7 @@ public class CustomNpcsPermissions {
public static final Permission GLOBAL_REMOTE = new Permission("customnpcs.global.remote");
// Save Globel Preferences
// Save Global Preferences
public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked");
public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata");
public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank");
@@ -706,15 +706,15 @@ public class NoppesUtilServer {
public static void sendMagicInfo(EntityPlayerMP player, boolean cycles) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
if (cycles) {
for (Magic magic : MagicController.getInstance().magics.values()) {
map.put(magic.name, magic.id);
}
sendScrollData(player, map, EnumScrollData.MAGIC);
} else {
for (MagicCycle magicCycle : MagicController.getInstance().cycles.values()) {
map.put(magicCycle.name, magicCycle.id);
}
sendScrollData(player, map, EnumScrollData.MAGIC_CYCLES);
} else {
for (Magic magic : MagicController.getInstance().magics.values()) {
map.put(magic.name, magic.id);
}
sendScrollData(player, map, EnumScrollData.MAGIC);
}
}
@@ -43,6 +43,7 @@ import noppes.npcs.client.fx.EntityRainbowFX;
import noppes.npcs.client.gui.*;
import noppes.npcs.client.gui.custom.GuiCustom;
import noppes.npcs.client.gui.global.*;
import noppes.npcs.client.gui.item.GuiNpcMagicBook;
import noppes.npcs.client.gui.item.GuiNpcPaintbrush;
import noppes.npcs.client.gui.mainmenu.*;
import noppes.npcs.client.gui.player.*;
@@ -422,6 +423,9 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.Paintbrush)
return new GuiNpcPaintbrush();
else if (gui == EnumGuiType.MagicBook)
return new GuiNpcMagicBook();
else if (gui == EnumGuiType.GlobalRemote)
return new GuiNPCGlobalMainMenu(null);
@@ -0,0 +1,176 @@
package noppes.npcs.client.gui.item;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket;
import kamkeel.npcs.network.packets.request.magic.MagicGetAllPacket;
import kamkeel.npcs.network.packets.request.magic.MagicGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.GuiMagicCycleMap;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.controllers.data.Magic;
import noppes.npcs.controllers.data.MagicCycle;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
public class GuiNpcMagicBook extends GuiNPCInterface implements ICustomScrollListener, IScrollData, IGuiData {
private MagicCycle magicCycle;
private GuiMagicCycleMap magicMap;
private GuiCustomScroll leftScroll;
public HashMap<String, Integer> cycleData = new HashMap<>();
public GuiNpcMagicBook() {
super();
xSize = 350;
setBackground("menubg.png");
closeOnEsc = true;
MagicCyclesPacket.GetAll();
}
@Override
public void initGui() {
super.initGui();
int spacing = 10;
int scrollWidth = 120;
addLabel(new GuiNpcLabel(0, "menu.cycles", guiLeft + 14, guiTop + 10, 0xFFFFFF));
// --- Left Scroll List ---
leftScroll = new GuiCustomScroll(this, 0, 0);
leftScroll.guiLeft = guiLeft + spacing;
leftScroll.guiTop = guiTop + 22;
leftScroll.setSize(scrollWidth, ySize - 32);
leftScroll.setList(new ArrayList<>(cycleData.keySet()));
addScroll(leftScroll);
// --- Magic Map (Diagram) on the Right ---
if(magicCycle == null)
return;
String displayName = magicCycle.getDisplayName().replace("&", "\u00A7");
leftScroll.setSelected(displayName);
int mapX = guiLeft + scrollWidth + 2 * spacing;
int mapY = guiTop + 22;
int mapWidth = xSize - (scrollWidth + 3 * spacing);
int mapHeight = ySize - 32;
magicMap = new GuiMagicCycleMap(this, mapX, mapY, mapWidth, mapHeight, magicCycle);
addDiagram(0, magicMap);
int labelY = guiTop + 10;
int textWidth = fontRendererObj.getStringWidth(displayName);
int labelX = mapX + (mapWidth / 2) - (textWidth / 2);
GuiNpcLabel magicLabel = new GuiNpcLabel(1, displayName, labelX, labelY, CustomNpcResourceListener.DefaultTextColor);
addLabel(magicLabel);
}
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
if (i == 1) {
close();
}
}
@Override
public void actionPerformed(GuiButton guibutton) {}
@Override
public void drawScreen(int i, int j, float f) {
super.drawScreen(i, j, f);
}
@Override
protected void drawBackground(){
super.drawBackground();
int spacing = 10;
int scrollWidth = 120;
int barHeight = 16; // Same height as the magic map bar
int barY = guiTop + 22 - barHeight - 1;
// Draw dark rectangle above the left scroll (same width as left scroll)
if (leftScroll != null) {
int leftRectX = guiLeft + spacing;
drawRect(leftRectX, barY, leftRectX + scrollWidth, barY + barHeight, 0xFF333333);
}
// Draw dark rectangle above the magic map
if (magicMap != null) {
int mapX = guiLeft + scrollWidth + 2 * spacing;
int mapWidth = xSize - (scrollWidth + 3 * spacing);
drawRect(mapX, barY, mapX + mapWidth, barY + barHeight, 0xFF333333);
}
}
@Override
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
if (magicMap != null) {
magicMap.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
if (magicMap != null) {
magicMap.mouseReleased(mouseX, mouseY, state);
}
super.mouseMovedOrUp(mouseX, mouseY, state);
}
@Override
public void save() {
// Implement save logic if needed.
}
// --- ICustomScrollListener Methods ---
@Override
public void customScrollClicked(int id, int index, int clickType, GuiCustomScroll scroll) {
if (scroll == leftScroll) {
String selectedName = scroll.getSelected();
MagicCyclesPacket.GetCycle(cycleData.get(selectedName));
}
}
@Override
public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {
// Handle double-click if necessary.
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data, EnumScrollData type) {
if(type == EnumScrollData.MAGIC_CYCLES){
cycleData.clear();
cycleData.putAll(data);
if (leftScroll != null) {
leftScroll.setList(new ArrayList<>(cycleData.keySet()));
}
initGui();
}
}
@Override
public void setSelected(String selected) {
}
@Override
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("MagicCycle")) {
magicCycle = new MagicCycle();
magicCycle.readNBT(compound.getCompoundTag("MagicCycle"));
initGui();
}
}
}
@@ -11,6 +11,7 @@ public class GuiNpcLabel {
public int x, y, color;
public boolean enabled = true;
public int id;
public boolean drawShadow = false;
public GuiNpcLabel(int id, Object label, int x, int y, int color) {
this.id = id;
@@ -26,7 +27,7 @@ public class GuiNpcLabel {
public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) {
if (enabled)
fontRenderer.drawString(label, x, y, color);
fontRenderer.drawString(label, x, y, color, drawShadow);
}
public void center(int width) {
@@ -27,6 +27,7 @@ public class ItemToolRenderer implements IItemRenderer {
private static final ResourceLocation PAINTBRUSH_HANDLE = new ResourceLocation("customnpcs", "textures/items/npcBrushHandle.png");
private static final ResourceLocation PAINTBRUSH_BRUSH = new ResourceLocation("customnpcs", "textures/items/npcBrushHair.png");
private static final ResourceLocation HAMMER = new ResourceLocation("customnpcs", "textures/items/npcToolHammer.png");
private static final ResourceLocation MAGIC_BOOK = new ResourceLocation("customnpcs", "textures/items/npcToolMagicBook.png");
private final Random random = new Random();
@@ -77,8 +78,10 @@ public class ItemToolRenderer implements IItemRenderer {
float blue = (color & 0xFF) / 255.0F;
GL11.glColor3f(red, green, blue);
renderEntityCustomItem(itemStack, entityItem, PAINTBRUSH_BRUSH);
} else {
} else if (itemStack.getItemDamage() == 0){
renderEntityCustomItem(itemStack, entityItem, HAMMER);
} else if (itemStack.getItemDamage() == 2){
renderEntityCustomItem(itemStack, entityItem, MAGIC_BOOK);
}
GL11.glPopMatrix();
return;
@@ -111,10 +114,14 @@ public class ItemToolRenderer implements IItemRenderer {
GL11.glPushMatrix();
renderItem3d(entityLivingBase, itemStack, PAINTBRUSH_BRUSH);
GL11.glPopMatrix();
} else {
} else if (itemStack.getItemDamage() == 0){
GL11.glPushMatrix();
renderItem3d(entityLivingBase, itemStack, HAMMER);
GL11.glPopMatrix();
} else if (itemStack.getItemDamage() == 2){
GL11.glPushMatrix();
renderItem3d(entityLivingBase, itemStack, MAGIC_BOOK);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
@@ -290,9 +297,12 @@ public class ItemToolRenderer implements IItemRenderer {
float blue = (color & 0xFF) / 255.0F;
textureManager.bindTexture(PAINTBRUSH_BRUSH);
renderCustomItemSlot(0, 0, 16, 16, red, green, blue);
} else {
} else if (itemStack.getItemDamage() == 0){
textureManager.bindTexture(HAMMER);
renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f);
} else if (itemStack.getItemDamage() == 2){
textureManager.bindTexture(MAGIC_BOOK);
renderCustomItemSlot(0, 0, 16, 16, 1.0f, 1.0f, 1.0f);
}
GL11.glEnable(GL11.GL_LIGHTING);
@@ -62,5 +62,6 @@ public enum EnumGuiType {
CustomGui,
ScriptItem,
ScriptBlock,
Paintbrush;
Paintbrush,
MagicBook;
}
@@ -2,6 +2,8 @@ package noppes.npcs.items;
import cpw.mods.fml.common.registry.GameRegistry;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.item.GuiMagicBookPacket;
import kamkeel.npcs.network.packets.player.item.GuiPaintbrushPacket;
import kamkeel.npcs.network.packets.request.item.ColorBrushPacket;
import kamkeel.npcs.network.packets.request.item.ColorSetPacket;
import kamkeel.npcs.network.packets.request.item.HammerPacket;
@@ -32,7 +34,7 @@ public class ItemNpcTool extends Item {
// Define our tool types based on metadata:
// meta 0: Hammer, meta 1: Paintbrush, meta 2: Wrench
public static final String[] toolTypes = new String[]{"hammer", "paintbrush"};
public static final String[] toolTypes = new String[]{"hammer", "paintbrush", "magic_book"};
public static String BRUSH_COLOR_TAG = "BrushColor";
public ItemNpcTool() {
@@ -62,13 +64,18 @@ public class ItemNpcTool extends Item {
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote)
if (!world.isRemote)
return stack;
if (isPaintbrush(stack) && player.isSneaking()) {
if (CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.PAINTBRUSH_GUI)) {
NoppesUtil.requestOpenGUI(EnumGuiType.Paintbrush);
PacketClient.sendClient(new GuiPaintbrushPacket(EnumGuiType.Paintbrush.ordinal(), 0, 0, 0));
}
return stack;
}
if (isMagicBook(stack)) {
PacketClient.sendClient(new GuiMagicBookPacket(EnumGuiType.MagicBook.ordinal(), 0, 0, 0));
return stack;
}
return stack;
}
@@ -145,6 +152,10 @@ public class ItemNpcTool extends Item {
return itemStack.getItemDamage() == 0;
}
public static boolean isMagicBook(ItemStack itemStack) {
return itemStack.getItemDamage() == 2;
}
@Override
public Item setUnlocalizedName(String name) {
GameRegistry.registerItem(this, name);