Complete Manage Linked Items / NPCs

This commit is contained in:
Kam committed 2025-02-18 04:29:38 -05:00
1 parent fdd47691ae
commit 030b44035e
7 files changed
+677 -271

No files matched your search

@@ -124,6 +124,10 @@ public enum EnumRequestPacket {
LinkedGetAll,
LinkedSet,
LinkedGet,
LinkedItemSave,
LinkedItemRemove,
LinkedItemBuild,
LinkedItemScript,
BankGet,
BanksGet,
@@ -180,5 +184,6 @@ public enum EnumRequestPacket {
EffectRemove,
EffectSave,
ColorSet, LinkedItemSave, LinkedItemRemove, LinkedItemBuild, LinkedItemScript, ColorBrush
ColorSet,
ColorBrush
}
@@ -65,8 +65,6 @@ public final class LinkedItemSavePacket extends AbstractPacket {
String prevName = ByteBufUtils.readString(in);
LinkedItem linkedItem = new LinkedItem();
linkedItem.readFromNBT(ByteBufUtils.readNBT(in));
linkedItem.version++;
LinkedItemController.getInstance().saveLinkedItem(linkedItem);
if(!prevName.isEmpty() && !prevName.equals(linkedItem.name)){
+21 -21
View File
@@ -11,7 +11,7 @@ import java.util.List;
public class DataAI {
private EntityNPCInterface npc;
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
public int doorInteract = 2;
public int findShelter = 2;
@@ -31,13 +31,13 @@ public class DataAI {
public int useRangeMelee = 0;
public int tacticalRadius = 8;
public int tacticalChance = 5;
public int movementType = 0;
public int movementType = 0; // 0 - Ground , 1 - Flying
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public boolean hasFlyLimit = true;
public int flyHeightLimit = 2;
public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody;
public EnumMovingType movingType = EnumMovingType.Standing;
@@ -59,7 +59,7 @@ public class DataAI {
this.npc = npc;
}
public void readToNBT(NBTTagCompound compound) {
public void readToNBT(NBTTagCompound compound) {
canSwim = compound.getBoolean("CanSwim");
reactsToFire = compound.getBoolean("ReactsToFire");
avoidsWater = compound.getBoolean("AvoidsWater");
@@ -79,21 +79,21 @@ public class DataAI {
movingPause = compound.getBoolean("MovingPause");
npcInteracting = compound.getBoolean("npcInteracting");
stopAndInteract = compound.getBoolean("stopAndInteract");
animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length];
standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length];
tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length];
combatPolicy = EnumCombatPolicy.values()[compound.getInteger("CombatPolicy") % EnumCombatPolicy.values().length];
orientation = compound.getInteger("Orientation");
bodyOffsetY = compound.getFloat("PositionOffsetY");
bodyOffsetZ = compound.getFloat("PositionOffsetZ");
bodyOffsetX = compound.getFloat("PositionOffsetX");
walkingRange = compound.getInteger("WalkingRange");
setWalkingSpeed(compound.getInteger("MoveSpeed"));
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
movingPos = compound.getInteger("MovingPos");
movingPattern = compound.getInteger("MovingPatern");
@@ -121,7 +121,7 @@ public class DataAI {
startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3){
startPos = new int[] {
startPos = new int[] {
MathHelper.floor_double(npc.posX),
MathHelper.floor_double(npc.posY),
MathHelper.floor_double(npc.posZ) };
@@ -154,14 +154,14 @@ public class DataAI {
compound.setInteger("MovingState", movingType.ordinal());
compound.setInteger("TacticalVariant", tacticalVariant.ordinal());
compound.setInteger("CombatPolicy", combatPolicy.ordinal());
compound.setInteger("Orientation", orientation);
compound.setFloat("PositionOffsetX", bodyOffsetX);
compound.setFloat("PositionOffsetY", bodyOffsetY);
compound.setFloat("PositionOffsetZ", bodyOffsetZ);
compound.setInteger("WalkingRange", walkingRange);
compound.setInteger("MoveSpeed", moveSpeed);
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
compound.setInteger("MovingPos", movingPos);
compound.setInteger("MovingPatern", movingPattern);
@@ -173,9 +173,9 @@ public class DataAI {
compound.setInteger("FlyHeightLimit", flyHeightLimit);
npc.setAvoidWater(avoidsWater);
compound.setIntArray("StartPosNew", npc.getStartPos());
return compound;
}
@@ -190,7 +190,7 @@ public class DataAI {
if(!movingPath.isEmpty())
startPos = movingPath.get(0);
}
public int[] getCurrentMovingPath(){
List<int[]> list = getMovingPath();
if(list.size() == 1){
@@ -206,14 +206,14 @@ public class DataAI {
}
else if(movingPos >= list.size()){
return list.get(list.size() - (movingPos % list.size()) - 2);
}
}
}
}
return list.get(movingPos);
}
public void incrementMovingPath(){
List<int[]> list = getMovingPath();
if(list.size() == 1){
@@ -229,7 +229,7 @@ public class DataAI {
movingPos = movingPos % size;
}
}
public void decreaseMovingPath() {
List<int[]> list = getMovingPath();
@@ -254,12 +254,12 @@ public class DataAI {
int[] pos = getCurrentMovingPath();
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
}
public void setWalkingSpeed(double speed){
this.moveSpeed = (int)speed;
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
}
public int getWalkingSpeed(){
return this.moveSpeed;
}
@@ -4,6 +4,7 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket;
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
import kamkeel.npcs.network.packets.request.linked.*;
import kamkeel.npcs.network.packets.request.quest.QuestSavePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -12,17 +13,22 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
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.SubGuiEditText;
import noppes.npcs.client.gui.item.SubGuiLinkedItem;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.CustomEffect;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Mouse;
@@ -35,7 +41,7 @@ import java.util.List;
import java.util.Vector;
public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback {
private int tab = 0;
private static int tab = 0;
private boolean loadedNPC = false;
private GuiCustomScroll scroll;
@@ -47,7 +53,7 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
private String search = "";
private float zoomed = 70, rotation;
private float zoomed = 36, rotation;
public GuiNPCManageLinked(EntityNPCInterface npc){
super(npc);
@@ -58,7 +64,10 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
this.npc.height = 1.62f;
this.npc.width = 0.43f;
LinkedGetAllPacket.GetNPCs();
if(tab == 0)
LinkedGetAllPacket.GetNPCs();
else if(tab == 1)
LinkedGetAllPacket.GetItems();
}
@Override
@@ -67,8 +76,8 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
int y = guiTop + 8;
this.addButton(new GuiNpcButton(10,guiLeft + 368, y, 45, 20, "npc"));
this.addButton(new GuiNpcButton(11,guiLeft + 368, y += 22, 45, 20, "items"));
this.addButton(new GuiNpcButton(10,guiLeft + 368, y, 45, 20, "gui.npcs"));
this.addButton(new GuiNpcButton(11,guiLeft + 368, y += 22, 45, 20, "gui.items"));
getButton(10).enabled = tab == 1;
getButton(11).enabled = tab == 0;
@@ -111,34 +120,28 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
@Override
public void drawScreen(int i, int j, float f) {
super.drawScreen(i, j, f);
if(hasSubGui())
return;
if(tab == 0){
if (hasSubGui())
return;
if(tab == 0) {
// (Existing NPC rendering code...)
if (isMouseOverRenderer(i, j)) {
zoomed += Mouse.getDWheel() * 0.035f;
if (zoomed > 100)
zoomed = 100;
if (zoomed < 10)
zoomed = 10;
if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
rotation -= Mouse.getDX() * 0.75f;
}
}
GL11.glColor4f(1, 1, 1, 1);
EntityLivingBase entity = this.npc;
int l = guiLeft + 150;
int i1 = guiTop + 198;
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glPushMatrix();
GL11.glTranslatef(l, i1, 60F);
GL11.glScalef(-zoomed, zoomed, zoomed);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
float f2 = entity.renderYawOffset;
@@ -150,28 +153,22 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-(float) Math.atan(f6 / 800F) * 20F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(-(float)Math.atan(f6 / 800F) * 20F, 1.0F, 0.0F, 0.0F);
entity.prevRenderYawOffset = entity.renderYawOffset = rotation;
entity.prevRotationYaw = entity.rotationYaw = (float) Math.atan(f5 / 80F) * 40F + rotation;
entity.rotationPitch = -(float) Math.atan(f6 / 80F) * 20F;
entity.prevRotationYaw = entity.rotationYaw = (float)Math.atan(f5 / 80F) * 40F + rotation;
entity.rotationPitch = -(float)Math.atan(f6 / 80F) * 20F;
entity.prevRotationYawHead = entity.rotationYawHead = entity.rotationYaw;
GL11.glTranslatef(0.0F, entity.yOffset, 1F);
RenderManager.instance.playerViewY = 180F;
// Render Entity
GL11.glPushMatrix();
try {
RenderManager.instance.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0.0F, 1.0F);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
GL11.glPopMatrix();
entity.prevRenderYawOffset = entity.renderYawOffset = f2;
entity.prevRotationYaw = entity.rotationYaw = f3;
entity.rotationPitch = f4;
entity.prevRotationYawHead = entity.rotationYawHead = f7;
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
@@ -180,7 +177,30 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glPopMatrix();
}
else if(tab == 1) {
// Render the linked item image in the top-left area
if(linkedItem != null) {
int x = guiLeft + 155;
int y = guiTop + 30;
int iconRenderSize = 64;
TextureManager textureManager = mc.getTextureManager();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
ImageData imageData = ClientCacheHandler.getImageData(linkedItem.display.texture);
if(imageData.imageLoaded()){
imageData.bindTexture();
int iconX = 0, iconY = 0;
int iconWidth = imageData.getTotalWidth();
int iconHeight = imageData.getTotalHeight();
int width = imageData.getTotalWidth();
int height = imageData.getTotalHeight();
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.glDisable(GL11.GL_DEPTH_TEST);
}
}
}
private List<String> getSearchList(){
@@ -236,6 +256,17 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
if(button.id == 3){
setSubGui(new SubGuiLinkedItem(this, this.linkedItem));
}
if(button.id == 4){
if (data.containsKey(scroll.getSelected()) && linkedItem != null && linkedItem.id >= 0) {
String name = linkedItem.name;
while (data.containsKey(name))
name += "_";
LinkedItem linkedItemClone = this.linkedItem.clone();
linkedItemClone.name = name;
linkedItemClone.id = -1;
PacketClient.sendClient(new LinkedItemSavePacket(linkedItemClone.writeToNBT(false), ""));
}
}
if(button.id == 5){
// Build Linked Item
if(tab == 1)
@@ -271,34 +302,206 @@ public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData,
private void renderScreen() {
// Draw the common background bars
drawGradientRect(guiLeft + 5, guiTop + 4, guiLeft + 218, guiTop + 24, 0xC0101010, 0xC0101010);
drawHorizontalLine(guiLeft + 5, guiLeft + 218, guiTop + 25, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
drawGradientRect(guiLeft + 5, guiTop + 27, guiLeft + 218, guiTop + ySize + 9, 0xA0101010, 0xA0101010);
if (tab == 0 && loadedNPC && this.npc != null) {
String drawString = npc.display.getName();
int textWidth = getStringWidthWithoutColor(drawString);
// Top bar: display NPC display name (centered)
String topBarText = npc.display.getName();
int textWidth = getStringWidthWithoutColor(topBarText);
int centerX = guiLeft + 5 + ((218 - 10 - textWidth) / 2);
fontRendererObj.drawString(drawString, centerX, guiTop + 10, npc.getFaction().color, true);
int y = guiTop + 18;
fontRendererObj.drawString(topBarText, centerX, guiTop + 10, npc.getFaction().color, true);
String healthMenu = "Health:";
fontRendererObj.drawString(healthMenu, guiLeft + 8, y += 12, 0xFFFFFF, true);
// Lower section: display NPC properties as label and value pairs
int y = guiTop + 30;
int xLabel = guiLeft + 8;
int xValue = guiLeft + 120;
int valueColor = 0xFFFFFF;
String label, value;
healthMenu = "§c" + String.valueOf(this.npc.stats.maxHealth);
fontRendererObj.drawString(healthMenu, guiLeft + 50, y, 0xFFFFFF, true);
// Health
label = StatCollector.translateToLocal("stats.health") + ": ";
value = String.valueOf(npc.stats.maxHealth);
fontRendererObj.drawString(label, xLabel, y, 0x29d6b9, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Damage (using getAttackStrength)
label = StatCollector.translateToLocal("stats.meleestrength") + ": ";
value = String.valueOf(npc.stats.getAttackStrength());
fontRendererObj.drawString(label, xLabel, y, 0xff5714, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
String damage = "Damage:";
fontRendererObj.drawString(damage, guiLeft + 8, y += 12, 0xFFFFFF, true);
// Attack Speed
label = StatCollector.translateToLocal("stats.meleespeed") + ": ";
value = String.valueOf(npc.stats.attackSpeed);
fontRendererObj.drawString(label, xLabel, y, 0xf7ca28, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
damage = "§4" + String.valueOf(this.npc.stats.getAttackStrength());
fontRendererObj.drawString(damage, guiLeft + 50, y, 0xFFFFFF, true);
// AI Type (npc.ai.onAttack: 0 = fight, 1 = panic, 2 = retreat, 3 = nothing)
label = StatCollector.translateToLocal("menu.ai") + ": ";
int onAttack = npc.ais.onAttack;
switch (onAttack) {
case 0:
value = StatCollector.translateToLocal("gui.retaliate");
break;
case 1:
value = StatCollector.translateToLocal("gui.panic");
break;
case 2:
value = StatCollector.translateToLocal("gui.retreat");
break;
case 3:
default:
value = StatCollector.translateToLocal("gui.nothing");
break;
}
fontRendererObj.drawString(label, xLabel, y, 0xce75fa, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
String moveSpeed = "Speed:";
fontRendererObj.drawString(moveSpeed, guiLeft + 8, y += 12, 0xFFFFFF, true);
// Walk Speed
label = StatCollector.translateToLocal("stats.speed") + ": ";
value = String.valueOf(npc.ais.getWalkingSpeed());
fontRendererObj.drawString(label, xLabel, y, 0xffae0d, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
moveSpeed = "§b" + String.valueOf(this.npc.ais.getWalkingSpeed());
fontRendererObj.drawString(moveSpeed, guiLeft + 50, y, 0xFFFFFF, true);
// Movement Type (0 = Ground, 1 = Flying)
label = StatCollector.translateToLocal("movement.type") + ": ";
int movementType = npc.ais.movementType;
if (movementType == 0) {
value = StatCollector.translateToLocal("movement.ground");
} else {
value = StatCollector.translateToLocal("movement.flying");
}
fontRendererObj.drawString(label, xLabel, y, 0x7cff54, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
}
if (tab == 1 && this.linkedItem != null) {
// Top bar: display the linked item's ID and name (centered)
String topBarText = StatCollector.translateToLocal("gui.id") + ": " + linkedItem.id + " - " + linkedItem.name;
int textWidth = getStringWidthWithoutColor(topBarText);
int centerX = guiLeft + 5 + ((218 - 10 - textWidth) / 2);
fontRendererObj.drawString(topBarText, centerX, guiTop + 10, 0xFFFFFF, true);
// Lower section: draw each property with a label (in a dimmer color) and its value (in white)
int y = guiTop + 30;
int xLabel = guiLeft + 8;
int xValue = guiLeft + 100;
int labelColor = 0xffae0d;
int valueColor = 0xFFFFFF;
String label, value;
// Version
label = StatCollector.translateToLocal("display.version") + ": ";
value = String.valueOf(linkedItem.version);
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Max Stack Size
labelColor = 0xff5714;
label = StatCollector.translateToLocal("display.maxStack") + ": ";
value = String.valueOf(linkedItem.stackSize);
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Dig Speed
labelColor = 0xf7ca28;
label = StatCollector.translateToLocal("display.digSpeed") + ": ";
value = String.valueOf(linkedItem.digSpeed);
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
labelColor = 0x29d6b9;
// Use Action
String[] useActions = {
StatCollector.translateToLocal("use_action.none"),
StatCollector.translateToLocal("use_action.block"),
StatCollector.translateToLocal("use_action.eat"),
StatCollector.translateToLocal("use_action.drink")
};
int useActionIndex;
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;
}
label = StatCollector.translateToLocal("display.useAction") + ": ";
value = useActions[useActionIndex];
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Armor Type
String[] armorOptions = {
StatCollector.translateToLocal("armor_type.none"),
StatCollector.translateToLocal("armor_type.all"),
StatCollector.translateToLocal("armor_type.head"),
StatCollector.translateToLocal("armor_type.chestplate"),
StatCollector.translateToLocal("armor_type.leggings"),
StatCollector.translateToLocal("armor_type.boots")
};
int armorIndex;
if (linkedItem.armorType == -2) {
armorIndex = 0;
} else if (linkedItem.armorType == -1) {
armorIndex = 1;
} else {
armorIndex = linkedItem.armorType + 2;
}
label = StatCollector.translateToLocal("display.armor") + ": ";
value = armorOptions[armorIndex];
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
labelColor = 0x7cff54;
// isTool
label = StatCollector.translateToLocal("display.isTool") + ": ";
value = String.valueOf(linkedItem.isTool).toUpperCase();
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// isNormalItem
label = StatCollector.translateToLocal("display.isNormalItem") + ": ";
value = String.valueOf(linkedItem.isNormalItem).toUpperCase();
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
labelColor = 0xce75fa;
// Scale
label = StatCollector.translateToLocal("model.scale") + ": ";
value = linkedItem.display.scaleX + ", " + linkedItem.display.scaleY + ", " + linkedItem.display.scaleZ;
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Rotation
label = StatCollector.translateToLocal("model.rotate") + ": ";
value = linkedItem.display.rotationX + ", " + linkedItem.display.rotationY + ", " + linkedItem.display.rotationZ;
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
y += 15;
// Translate
label = StatCollector.translateToLocal("model.translate") + ": ";
value = linkedItem.display.translateX + ", " + linkedItem.display.translateY + ", " + linkedItem.display.translateZ;
fontRendererObj.drawString(label, xLabel, y, labelColor, false);
fontRendererObj.drawString(value, xValue, y, valueColor, false);
}
}
@@ -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();
}
}
}
@@ -13,6 +13,7 @@ import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.LinkedItem;
@@ -32,7 +33,6 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
public final LinkedItem linkedItem;
private final LinkedItemScript scriptHandler;
public GuiScriptLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
this.drawDefaultBackground = true;
this.closeOnEsc = true;
@@ -43,18 +43,20 @@ public class GuiScriptLinkedItem extends GuiNPCInterface implements GuiYesNoCall
this.linkedItem = linkedItem;
this.scriptHandler = new LinkedItemScript();
hookList.add("init");
hookList.add("tick");
hookList.add("tossed");
hookList.add("pickedUp");
hookList.add("spawn");
hookList.add("interact");
hookList.add("rightClick");
hookList.add("attack");
hookList.add("startItem");
hookList.add("usingItem");
hookList.add("stopItem");
hookList.add("finishItem");
hookList.add(EnumScriptType.LINKED_ITEM_BUILD.name());
hookList.add(EnumScriptType.LINKED_ITEM_VERSION.name());
hookList.add(EnumScriptType.INIT.name());
hookList.add(EnumScriptType.TICK.name());
hookList.add(EnumScriptType.TOSSED.name());
hookList.add(EnumScriptType.PICKEDUP.name());
hookList.add(EnumScriptType.SPAWN.name());
hookList.add(EnumScriptType.INTERACT.name());
hookList.add(EnumScriptType.RIGHT_CLICK.name());
hookList.add(EnumScriptType.ATTACK.name());
hookList.add(EnumScriptType.START_USING_ITEM.name());
hookList.add(EnumScriptType.USING_ITEM.name());
hookList.add(EnumScriptType.STOP_USING_ITEM.name());
hookList.add(EnumScriptType.FINISH_USING_ITEM.name());
LinkedItemScriptPacket.Get(linkedItem.id);
}