mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 14:19:49 +00:00
Complete Manage Linked Items / NPCs
This commit is contained in:
1 parent
fdd47691ae
commit
030b44035e
7 files changed
+677
-271
No files matched your search
@@ -2,17 +2,36 @@ package noppes.npcs.client.gui.item;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedItemSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedNPCAddPacket;
|
||||
import kamkeel.npcs.util.ColorUtil;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.SubGuiEditText;
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
|
||||
import noppes.npcs.client.gui.script.GuiScriptLinkedItem;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.controllers.data.LinkedItem;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListener, GuiYesNoCallback, ISubGuiListener {
|
||||
|
||||
public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListener {
|
||||
private final GuiNPCManageLinked parent;
|
||||
public LinkedItem linkedItem;
|
||||
private final String originalName;
|
||||
|
||||
private int tab = -1;
|
||||
private int colorPicked = 0;
|
||||
|
||||
public SubGuiLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
|
||||
this.linkedItem = linkedItem;
|
||||
this.parent = parent;
|
||||
@@ -27,183 +46,301 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
// Top buttons
|
||||
GuiMenuTopButton close = new GuiMenuTopButton(-5, guiLeft + xSize - 22, guiTop - 10, "X");
|
||||
|
||||
GuiMenuTopButton general = new GuiMenuTopButton(-1, guiLeft + 4, guiTop - 10, "menu.general");
|
||||
GuiMenuTopButton scripts = new GuiMenuTopButton(-2, general.xPosition + general.getWidth(), guiTop - 10, "script.scripts");
|
||||
GuiMenuTopButton advanced = new GuiMenuTopButton(-2, general.xPosition + general.getWidth(), guiTop - 10, "menu.advanced");
|
||||
GuiMenuTopButton scripts = new GuiMenuTopButton(-3, advanced.xPosition + advanced.getWidth(), guiTop - 10, "script.scripts");
|
||||
|
||||
close.active = false;
|
||||
general.active = true;
|
||||
scripts.active = false;
|
||||
// Set active tab
|
||||
general.active = (tab == -1 || tab == 0);
|
||||
advanced.active = (tab == -2);
|
||||
scripts.active = (tab == -3);
|
||||
close.active = (tab == -5);
|
||||
|
||||
addTopButton(close);
|
||||
addTopButton(advanced);
|
||||
addTopButton(general);
|
||||
addTopButton(scripts);
|
||||
|
||||
guiTop += 7;
|
||||
int y = guiTop + 7;
|
||||
int x = guiLeft + 4;
|
||||
y += 5;
|
||||
|
||||
GuiScrollWindow scrollWindow = new GuiScrollWindow(this, x + 5, y, xSize - 20, ySize - 10 - (y - guiTop), 0);
|
||||
addScrollableGui(0, scrollWindow);
|
||||
|
||||
y = 5;
|
||||
x = 5;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(1, "display.name", x, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(1, this, x + 80, y, scrollWindow.clipWidth - 20 - 80, 20, linkedItem.name));
|
||||
scrollWindow.getTextField(1).setMaxStringLength(100);
|
||||
|
||||
y += 25;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(2, "display.texture", x, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(2, this, x + 80, y, scrollWindow.clipWidth - 20 - 80, 20, linkedItem.display.texture));
|
||||
scrollWindow.getTextField(2).setMaxStringLength(300);
|
||||
|
||||
y += 30;
|
||||
|
||||
String color = Integer.toHexString(linkedItem.display.itemColor);
|
||||
while(color.length() < 6)
|
||||
color = "0" + color;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(9, "display.color", x, y + 5, 0xFFFFFF));
|
||||
x += 35;
|
||||
scrollWindow.addButton(new GuiNpcButton(9, x + 80, y, 80, 20, color + ""));
|
||||
scrollWindow.getButton(9).packedFGColour = linkedItem.display.itemColor;
|
||||
|
||||
x = 5;
|
||||
|
||||
y += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(10, "display.isTool", x, y + 5, 0xFFFFFF));
|
||||
x += 35;
|
||||
scrollWindow.addButton(new GuiNpcButtonYesNo(10, x + 80, y, linkedItem.isTool));
|
||||
|
||||
x = 5;
|
||||
y += 25;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(11, "display.isNormalItem", x, y + 5, 0xFFFFFF));
|
||||
x += 35;
|
||||
scrollWindow.addButton(new GuiNpcButtonYesNo(11, x + 80, y, linkedItem.isNormalItem));
|
||||
|
||||
x = 5;
|
||||
|
||||
y += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(3, "display.scale", x, y + 5, 0xFFFFFF));
|
||||
|
||||
x += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(31, "X", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(31, this, x + 90, y, 40, 20, linkedItem.display.scaleX + ""));
|
||||
scrollWindow.getTextField(31).setFloatsOnly();
|
||||
scrollWindow.getTextField(31).setMinMaxDefaultFloat(0, 30, 1);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(32, "Y", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(32, this, x + 90, y, 40, 20, linkedItem.display.scaleY + ""));
|
||||
scrollWindow.getTextField(32).setFloatsOnly();
|
||||
scrollWindow.getTextField(32).setMinMaxDefaultFloat(0, 30, 1);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(33, "Z", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(33, this, x + 90, y, 40, 20, linkedItem.display.scaleZ + ""));
|
||||
scrollWindow.getTextField(33).setFloatsOnly();
|
||||
scrollWindow.getTextField(33).setMinMaxDefaultFloat(0, 30, 1);
|
||||
|
||||
x = 5;
|
||||
y += 25;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(4, "display.rotation", x, y + 5, 0xFFFFFF));
|
||||
|
||||
x += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(41, "X", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(41, this, x + 90, y, 40, 20, linkedItem.display.rotationX + ""));
|
||||
scrollWindow.getTextField(41).setFloatsOnly();
|
||||
scrollWindow.getTextField(41).setMinMaxDefaultFloat(-360, 360, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(42, "Y", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(42, this, x + 90, y, 40, 20, linkedItem.display.rotationY + ""));
|
||||
scrollWindow.getTextField(42).setFloatsOnly();
|
||||
scrollWindow.getTextField(42).setMinMaxDefaultFloat(-360, 360, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(43, "Z", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(43, this, x + 90, y, 40, 20, linkedItem.display.rotationZ + ""));
|
||||
scrollWindow.getTextField(43).setFloatsOnly();
|
||||
scrollWindow.getTextField(43).setMinMaxDefaultFloat(-360, 360, 0);
|
||||
|
||||
x = 5;
|
||||
y += 25;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(5, "display.rotationRate", x, y + 5, 0xFFFFFF));
|
||||
|
||||
x += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(51, "X", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(51, this, x + 90, y, 40, 20, linkedItem.display.rotationXRate + ""));
|
||||
scrollWindow.getTextField(51).setFloatsOnly();
|
||||
scrollWindow.getTextField(51).setMinMaxDefaultFloat(0, 100, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(52, "Y", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(52, this, x + 90, y, 40, 20, linkedItem.display.rotationYRate + ""));
|
||||
scrollWindow.getTextField(52).setFloatsOnly();
|
||||
scrollWindow.getTextField(52).setMinMaxDefaultFloat(0, 100, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(53, "Z", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(53, this, x + 90, y, 40, 20, linkedItem.display.rotationZRate + ""));
|
||||
scrollWindow.getTextField(53).setFloatsOnly();
|
||||
scrollWindow.getTextField(53).setMinMaxDefaultFloat(0, 100, 0);
|
||||
|
||||
x = 5;
|
||||
y += 25;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(6, "display.translate", x, y + 5, 0xFFFFFF));
|
||||
|
||||
x += 30;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(61, "X", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(61, this, x + 90, y, 40, 20, linkedItem.display.translateX + ""));
|
||||
scrollWindow.getTextField(61).setFloatsOnly();
|
||||
scrollWindow.getTextField(61).setMinMaxDefaultFloat(-10, 10, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(62, "Y", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(62, this, x + 90, y, 40, 20, linkedItem.display.translateY + ""));
|
||||
scrollWindow.getTextField(62).setFloatsOnly();
|
||||
scrollWindow.getTextField(62).setMinMaxDefaultFloat(-10, 10, 0);
|
||||
|
||||
x += 70;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(63, "Z", x + 80, y + 5, 0xFFFFFF));
|
||||
scrollWindow.addTextField(new GuiNpcTextField(63, this, x + 90, y, 40, 20, linkedItem.display.translateZ + ""));
|
||||
scrollWindow.getTextField(63).setFloatsOnly();
|
||||
scrollWindow.getTextField(63).setMinMaxDefaultFloat(-10, 10, 0);
|
||||
|
||||
y += 30;
|
||||
|
||||
scrollWindow.scrollY = 0;
|
||||
scrollWindow.maxScrollY = y - scrollWindow.clipHeight;
|
||||
if (general.active) {
|
||||
addGeneralComponents();
|
||||
} else if (advanced.active) {
|
||||
addAdvancedComponents();
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== GENERAL TAB COMPONENTS =====================
|
||||
private void addGeneralComponents() {
|
||||
int x = guiLeft + 10;
|
||||
int y = guiTop + 8;
|
||||
int spacing = 25;
|
||||
|
||||
// NAME + ID label
|
||||
addLabel(new GuiNpcLabel(1, "gui.name", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
addTextField(new GuiNpcTextField(1, this, x + 60, y, 180, 20, linkedItem.name));
|
||||
addLabel(new GuiNpcLabel(100, "gui.id", x + 250, y + 1, CustomNpcResourceListener.DefaultTextColor));
|
||||
addLabel(new GuiNpcLabel(101, linkedItem.id + "", x + 250, y + 11, CustomNpcResourceListener.DefaultTextColor));
|
||||
y += spacing;
|
||||
|
||||
// VERSION + Bump Button
|
||||
addLabel(new GuiNpcLabel(2, "display.version", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
GuiNpcButton versionButton = new GuiNpcButton(20, x + 100, y, 80, 20, "gui.update");
|
||||
versionButton.setHoverText("display.versionInfo");
|
||||
addButton(versionButton);
|
||||
addLabel(new GuiNpcLabel(200, "display.version", x + 190, y + 1, CustomNpcResourceListener.DefaultTextColor));
|
||||
addLabel(new GuiNpcLabel(201, linkedItem.version + "", x + 190, y + 11, CustomNpcResourceListener.DefaultTextColor));
|
||||
|
||||
y += spacing;
|
||||
|
||||
// MAX STACKSIZE field (integers only, 1 to 64)
|
||||
addLabel(new GuiNpcLabel(4, "display.maxStack", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
GuiNpcTextField stackField = new GuiNpcTextField(3, this, x + 110, y, 50, 20, "" + linkedItem.stackSize);
|
||||
stackField.setIntegersOnly().setMinMaxDefault(1, 64, 64);
|
||||
addTextField(stackField);
|
||||
|
||||
y += spacing;
|
||||
|
||||
// Enchantability field (0 to 30)
|
||||
addLabel(new GuiNpcLabel(9, "display.enchantability", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
GuiNpcTextField enchantField = new GuiNpcTextField(10, this, x + 110, y, 50, 20, "" + linkedItem.enchantability);
|
||||
enchantField.setIntegersOnly().setMinMaxDefault(0, 30, 0);
|
||||
addTextField(enchantField);
|
||||
y += spacing;
|
||||
|
||||
// Dig Speed field (0 to 20)
|
||||
addLabel(new GuiNpcLabel(11, "display.digSpeed", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
GuiNpcTextField digSpeedField = new GuiNpcTextField(12, this, x + 110, y, 50, 20, "" + linkedItem.digSpeed);
|
||||
digSpeedField.setIntegersOnly().setMinMaxDefault(0, 20, 1);
|
||||
addTextField(digSpeedField);
|
||||
|
||||
y += spacing;
|
||||
|
||||
// TEXTURE field
|
||||
addLabel(new GuiNpcLabel(3, "display.texture", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
addTextField(new GuiNpcTextField(2, this, x + 60, y, 200, 20, linkedItem.display.texture));
|
||||
|
||||
y += spacing;
|
||||
|
||||
// Item Use Action: BiDirectional button (None, Block, Eat, Drink)
|
||||
addLabel(new GuiNpcLabel(5, "display.useAction", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
String[] useActions = {"use_action.none", "use_action.block", "use_action.eat", "use_action.drink"};
|
||||
int useActionIndex = 0;
|
||||
switch(linkedItem.itemUseAction) {
|
||||
case 0: useActionIndex = 0; break;
|
||||
case 1: useActionIndex = 1; break;
|
||||
case 3: useActionIndex = 2; break;
|
||||
case 4: useActionIndex = 3; break;
|
||||
default: useActionIndex = 0; break;
|
||||
}
|
||||
GuiButtonBiDirectional useActionButton = new GuiButtonBiDirectional(6, x + 120, y, 100, 20, useActions, useActionIndex);
|
||||
addButton(useActionButton);
|
||||
y += spacing;
|
||||
|
||||
// Armor Type: BiDirectional button (None, All, Head, Chestplate, Leggings, Boots)
|
||||
addLabel(new GuiNpcLabel(7, "display.armor", x, y + 5, CustomNpcResourceListener.DefaultTextColor));
|
||||
String[] armorOptions = {"armor_type.none", "armor_type.all", "armor_type.head", "armor_type.chestplate", "armor_type.leggings", "armor_type.boots"};
|
||||
int armorIndex;
|
||||
if (linkedItem.armorType == -2) {
|
||||
armorIndex = 0;
|
||||
} else if (linkedItem.armorType == -1) {
|
||||
armorIndex = 1;
|
||||
} else {
|
||||
armorIndex = linkedItem.armorType + 2; // 0->2, 1->3, etc.
|
||||
}
|
||||
GuiButtonBiDirectional armorButton = new GuiButtonBiDirectional(8, x + 120, y, 100, 20, armorOptions, armorIndex);
|
||||
addButton(armorButton);
|
||||
y += spacing;
|
||||
}
|
||||
|
||||
// ===================== ADVANCED TAB COMPONENTS =====================
|
||||
private void addAdvancedComponents() {
|
||||
int x = 5;
|
||||
int y = 5;
|
||||
int clipWidth = xSize - 20;
|
||||
int clipHeight = ySize - 20;
|
||||
GuiScrollWindow scrollWindow = new GuiScrollWindow(this, guiLeft + 10, guiTop + 10, clipWidth, clipHeight, 0);
|
||||
addScrollableGui(0, scrollWindow);
|
||||
|
||||
int localY = 5;
|
||||
// Item Color: label and two buttons
|
||||
scrollWindow.addLabel(new GuiNpcLabel(20, "gui.color", x, localY + 5, 0xFFFFFF));
|
||||
String colorHex = Integer.toHexString(linkedItem.display.itemColor);
|
||||
while(colorHex.length() < 6)
|
||||
colorHex = "0" + colorHex;
|
||||
GuiNpcButton colorPickerButton = new GuiNpcButton(24, x + 80, localY, 80, 20, colorHex);
|
||||
colorPickerButton.packedFGColour = linkedItem.display.itemColor;
|
||||
scrollWindow.addButton(colorPickerButton);
|
||||
GuiNpcButton clearColorButton = new GuiNpcButton(25, x + 170, localY, 60, 20, "gui.clear");
|
||||
scrollWindow.addButton(clearColorButton);
|
||||
localY += 30;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(27, "display.isTool", x, localY + 5, 0xFFFFFF));
|
||||
GuiNpcButtonYesNo toolButton = new GuiNpcButtonYesNo(27, x + 120, localY, linkedItem.isTool);
|
||||
toolButton.setHoverText("display.isToolInfo");
|
||||
scrollWindow.addButton(toolButton);
|
||||
localY += 25;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(28, "display.isNormalItem", x, localY + 5, 0xFFFFFF));
|
||||
GuiNpcButtonYesNo normalButton = new GuiNpcButtonYesNo(28, x + 120, localY, linkedItem.isNormalItem);
|
||||
normalButton.setHoverText("display.isNormalItemInfo");
|
||||
scrollWindow.addButton(normalButton);
|
||||
localY += 25;
|
||||
|
||||
// Scale: X, Y, Z
|
||||
scrollWindow.addLabel(new GuiNpcLabel(31, "model.scale", x, localY + 5, 0xFFFFFF));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(32, "X", x + 80, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField scaleXField = new GuiNpcTextField(31, this, x + 90, localY, 40, 20, linkedItem.display.scaleX + "");
|
||||
scaleXField.setFloatsOnly().setMinMaxDefaultFloat(0, 30, 1);
|
||||
scrollWindow.addTextField(scaleXField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(33, "Y", x + 140, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField scaleYField = new GuiNpcTextField(32, this, x + 150, localY, 40, 20, linkedItem.display.scaleY + "");
|
||||
scaleYField.setFloatsOnly().setMinMaxDefaultFloat(0, 30, 1);
|
||||
scrollWindow.addTextField(scaleYField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(34, "Z", x + 200, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField scaleZField = new GuiNpcTextField(33, this, x + 210, localY, 40, 20, linkedItem.display.scaleZ + "");
|
||||
scaleZField.setFloatsOnly().setMinMaxDefaultFloat(0, 30, 1);
|
||||
scrollWindow.addTextField(scaleZField);
|
||||
localY += 30;
|
||||
|
||||
// Rotation: X, Y, Z
|
||||
scrollWindow.addLabel(new GuiNpcLabel(41, "model.rotate", x, localY + 5, 0xFFFFFF));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(42, "X", x + 80, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotXField = new GuiNpcTextField(41, this, x + 90, localY, 40, 20, linkedItem.display.rotationX + "");
|
||||
rotXField.setFloatsOnly().setMinMaxDefaultFloat(-360, 360, 0);
|
||||
scrollWindow.addTextField(rotXField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(43, "Y", x + 140, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotYField = new GuiNpcTextField(42, this, x + 150, localY, 40, 20, linkedItem.display.rotationY + "");
|
||||
rotYField.setFloatsOnly().setMinMaxDefaultFloat(-360, 360, 0);
|
||||
scrollWindow.addTextField(rotYField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(44, "Z", x + 200, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotZField = new GuiNpcTextField(43, this, x + 210, localY, 40, 20, linkedItem.display.rotationZ + "");
|
||||
rotZField.setFloatsOnly().setMinMaxDefaultFloat(-360, 360, 0);
|
||||
scrollWindow.addTextField(rotZField);
|
||||
localY += 30;
|
||||
|
||||
// Rotation Rate: X, Y, Z
|
||||
scrollWindow.addLabel(new GuiNpcLabel(51, "model.rotationRate", x, localY + 5, 0xFFFFFF));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(52, "X", x + 80, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotXRateField = new GuiNpcTextField(51, this, x + 90, localY, 40, 20, linkedItem.display.rotationXRate + "");
|
||||
rotXRateField.setFloatsOnly().setMinMaxDefaultFloat(0, 100, 0);
|
||||
scrollWindow.addTextField(rotXRateField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(53, "Y", x + 140, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotYRateField = new GuiNpcTextField(52, this, x + 150, localY, 40, 20, linkedItem.display.rotationYRate + "");
|
||||
rotYRateField.setFloatsOnly().setMinMaxDefaultFloat(0, 100, 0);
|
||||
scrollWindow.addTextField(rotYRateField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(54, "Z", x + 200, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField rotZRateField = new GuiNpcTextField(53, this, x + 210, localY, 40, 20, linkedItem.display.rotationZRate + "");
|
||||
rotZRateField.setFloatsOnly().setMinMaxDefaultFloat(0, 100, 0);
|
||||
scrollWindow.addTextField(rotZRateField);
|
||||
localY += 30;
|
||||
|
||||
// Translate: X, Y, Z
|
||||
scrollWindow.addLabel(new GuiNpcLabel(61, "model.translate", x, localY + 5, 0xFFFFFF));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(62, "X", x + 80, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField transXField = new GuiNpcTextField(61, this, x + 90, localY, 40, 20, linkedItem.display.translateX + "");
|
||||
transXField.setFloatsOnly().setMinMaxDefaultFloat(-10, 10, 0);
|
||||
scrollWindow.addTextField(transXField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(63, "Y", x + 140, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField transYField = new GuiNpcTextField(62, this, x + 150, localY, 40, 20, linkedItem.display.translateY + "");
|
||||
transYField.setFloatsOnly().setMinMaxDefaultFloat(-10, 10, 0);
|
||||
scrollWindow.addTextField(transYField);
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(64, "Z", x + 200, localY + 5, 0xFFFFFF));
|
||||
GuiNpcTextField transZField = new GuiNpcTextField(63, this, x + 210, localY, 40, 20, linkedItem.display.translateZ + "");
|
||||
transZField.setFloatsOnly().setMinMaxDefaultFloat(-10, 10, 0);
|
||||
scrollWindow.addTextField(transZField);
|
||||
localY += 30;
|
||||
|
||||
// Durability Show toggle (Yes/No button)
|
||||
scrollWindow.addLabel(new GuiNpcLabel(70, "display.durabilityShow", x, localY + 5, 0xFFFFFF));
|
||||
GuiNpcButtonYesNo durabilityButton = new GuiNpcButtonYesNo(26, x + 120, localY, linkedItem.display.durabilityShow);
|
||||
scrollWindow.addButton(durabilityButton);
|
||||
|
||||
scrollWindow.scrollY = 0;
|
||||
scrollWindow.maxScrollY = Math.max(localY - scrollWindow.clipHeight, 0);
|
||||
}
|
||||
|
||||
// ===================== BUTTON & TEXTFIELD HANDLING =====================
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
if (id == -5) {
|
||||
close();
|
||||
return;
|
||||
} else if (id == -2) {
|
||||
} else if (id == -1 && tab != -1) {
|
||||
tab = -1;
|
||||
initGui();
|
||||
return;
|
||||
} else if (id == -2 && tab != -2) {
|
||||
tab = -2;
|
||||
initGui();
|
||||
return;
|
||||
} else if (id == -3) {
|
||||
PacketClient.sendClient(new LinkedItemSavePacket(linkedItem.writeToNBT(false), originalName));
|
||||
GuiScriptLinkedItem scriptGUI = new GuiScriptLinkedItem(this.parent, linkedItem);
|
||||
scriptGUI.setWorldAndResolution(mc, width, height);
|
||||
scriptGUI.initGui();
|
||||
mc.currentScreen = scriptGUI;
|
||||
} else if (id == 9) {
|
||||
// OPEN COLOR PICKER
|
||||
} else if (id == 10) {
|
||||
// IsTool
|
||||
if (guibutton instanceof GuiNpcButtonYesNo) {
|
||||
linkedItem.isTool = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
return;
|
||||
} else if (id == 20) {
|
||||
// Open confirmation for version bump.
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", "Bump version and update all linked items?", 20);
|
||||
displayGuiScreen(guiyesno);
|
||||
return;
|
||||
} else if (id == 24) {
|
||||
setSubGui(new SubGuiColorSelector(linkedItem.display.itemColor));
|
||||
colorPicked = 1;
|
||||
return;
|
||||
} else if (id == 25) {
|
||||
// Clear color: set to 0xFFFFFF.
|
||||
linkedItem.display.itemColor = 0xFFFFFF;
|
||||
GuiScrollWindow scrollWindow = getScrollableGui(0);
|
||||
if(scrollWindow != null){
|
||||
GuiNpcButton npcButton = scrollWindow.getButton(24);
|
||||
if(npcButton != null){
|
||||
npcButton.displayString = "ffffff";
|
||||
npcButton.packedFGColour = 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
} else if (id == 11) {
|
||||
// isNormalItem
|
||||
if (guibutton instanceof GuiNpcButtonYesNo) {
|
||||
linkedItem.isNormalItem = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
} else if (id == 6) {
|
||||
// Item Use Action button.
|
||||
int index = ((GuiButtonBiDirectional) guibutton).getValue();
|
||||
switch(index) {
|
||||
case 0: linkedItem.itemUseAction = 0; break;
|
||||
case 1: linkedItem.itemUseAction = 1; break;
|
||||
case 2: linkedItem.itemUseAction = 3; break;
|
||||
case 3: linkedItem.itemUseAction = 4; break;
|
||||
}
|
||||
} else if (id == 8) {
|
||||
// Armor Type button.
|
||||
int index = ((GuiButtonBiDirectional) guibutton).getValue();
|
||||
switch(index) {
|
||||
case 0: linkedItem.armorType = -2; break;
|
||||
case 1: linkedItem.armorType = -1; break;
|
||||
case 2: linkedItem.armorType = 0; break;
|
||||
case 3: linkedItem.armorType = 1; break;
|
||||
case 4: linkedItem.armorType = 2; break;
|
||||
case 5: linkedItem.armorType = 3; break;
|
||||
}
|
||||
} else if (id == 27 && guibutton instanceof GuiNpcButtonYesNo) {
|
||||
// IsTool toggle
|
||||
linkedItem.isTool = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
} else if (id == 28 && guibutton instanceof GuiNpcButtonYesNo) {
|
||||
// IsNormalItem toggle
|
||||
linkedItem.isNormalItem = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
} else if (id == 26 && guibutton instanceof GuiNpcButtonYesNo) {
|
||||
linkedItem.display.durabilityShow = ((GuiNpcButtonYesNo) guibutton).getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,78 +353,109 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
|
||||
} else if (id == 2) {
|
||||
// Texture
|
||||
linkedItem.display.texture = textField.getText();
|
||||
} else if (id == 3) {
|
||||
// Max StackSize
|
||||
linkedItem.stackSize = textField.getInteger();
|
||||
} else if (id == 10) {
|
||||
// Enchantability
|
||||
linkedItem.enchantability = textField.getInteger();
|
||||
} else if (id == 12) {
|
||||
// Dig Speed
|
||||
linkedItem.digSpeed = textField.getInteger();
|
||||
} else if (id == 31) {
|
||||
// Scale X
|
||||
linkedItem.display.scaleX = textField.getFloat();
|
||||
} else if (id == 32) {
|
||||
// Scale Y
|
||||
linkedItem.display.scaleY = textField.getFloat();
|
||||
} else if (id == 33) {
|
||||
// Scale Z
|
||||
linkedItem.display.scaleZ = textField.getFloat();
|
||||
} else if (id == 41) {
|
||||
// Rotation X
|
||||
linkedItem.display.rotationX = textField.getFloat();
|
||||
} else if (id == 42) {
|
||||
// Rotation Y
|
||||
linkedItem.display.rotationY = textField.getFloat();
|
||||
} else if (id == 43) {
|
||||
// Rotation Z
|
||||
linkedItem.display.rotationZ = textField.getFloat();
|
||||
} else if (id == 51) {
|
||||
// Rotation X Rate
|
||||
linkedItem.display.rotationXRate = textField.getFloat();
|
||||
} else if (id == 52) {
|
||||
// Rotation Y Rate
|
||||
linkedItem.display.rotationYRate = textField.getFloat();
|
||||
} else if (id == 53) {
|
||||
// Rotation Z Rate
|
||||
linkedItem.display.rotationZRate = textField.getFloat();
|
||||
} else if (id == 61) {
|
||||
// Translate X
|
||||
linkedItem.display.translateX = textField.getFloat();
|
||||
} else if (id == 62) {
|
||||
// Translate Y
|
||||
linkedItem.display.translateY = textField.getFloat();
|
||||
} else if (id == 63) {
|
||||
// Translate Z
|
||||
linkedItem.display.translateZ = textField.getFloat();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean flag, int id) {
|
||||
if (id == 20 && flag) {
|
||||
linkedItem.version++;
|
||||
initGui();
|
||||
}
|
||||
mc.currentScreen = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground() {
|
||||
super.drawBackground();
|
||||
renderScreen();
|
||||
}
|
||||
|
||||
private void renderScreen() {
|
||||
if (tab != -1)
|
||||
return;
|
||||
|
||||
int y = guiTop + 36;
|
||||
int x = guiLeft + 250;
|
||||
|
||||
int iconRenderSize = 86;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
TextureManager textureManager = mc.getTextureManager();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ImageData data = ClientCacheHandler.getImageData(linkedItem.display.texture);
|
||||
if (data.imageLoaded()) {
|
||||
data.bindTexture();
|
||||
int iconX = 0;
|
||||
int iconY = 0;
|
||||
int iconWidth = data.getTotalWidth();
|
||||
int iconHeight = data.getTotalWidth();
|
||||
int width = data.getTotalWidth();
|
||||
int height = data.getTotalWidth();
|
||||
|
||||
float[] colors = ColorUtil.hexToRGB(linkedItem.display.itemColor);
|
||||
GL11.glColor3f(colors[0], colors[1], colors[2]);
|
||||
func_152125_a(x, y, iconX, iconY, iconWidth, iconHeight, iconRenderSize, iconRenderSize, width, height);
|
||||
} else {
|
||||
textureManager.bindTexture(new ResourceLocation("customnpcs", "textures/marks/question.png"));
|
||||
func_152125_a(x, y, 0, 0, 1, 1, iconRenderSize, iconRenderSize, 1, 1);
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
PacketClient.sendClient(new LinkedItemSavePacket(linkedItem.writeToNBT(false), originalName));
|
||||
}
|
||||
|
||||
public enum LinkedItemType {
|
||||
TOOL,
|
||||
NORMAL
|
||||
}
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if(subgui instanceof SubGuiColorSelector){
|
||||
if(colorPicked == 1)
|
||||
linkedItem.display.itemColor = ((SubGuiColorSelector) subgui).color;
|
||||
if(colorPicked == 2)
|
||||
linkedItem.display.durabilityColor = ((SubGuiColorSelector) subgui).color;
|
||||
|
||||
public enum LinkedItemUseAction {
|
||||
NONE,
|
||||
BLOCK,
|
||||
BOW,
|
||||
EAT,
|
||||
DRINK
|
||||
}
|
||||
|
||||
public enum LinkedItemArmorType {
|
||||
NONE(-2, "none"),
|
||||
ALL(-1, "all"),
|
||||
HELM(0, "helm"),
|
||||
CHESTPLATE(1, "chestplate"),
|
||||
LEGGINGS(2, "leggings"),
|
||||
BOOTS(3, "boots");
|
||||
|
||||
public int value;
|
||||
public String name;
|
||||
|
||||
LinkedItemArmorType(int type, String display){
|
||||
this.value = type;
|
||||
this.name = display;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user