mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 12:25:59 +00:00
Magic Book Item + Magic Player Packets
This commit is contained in:
1 parent
62046b10e6
commit
3e10207b41
19 files changed
+466
-18
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user