mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Some GUI and Packet Fixes
This commit is contained in:
1 parent
270cb26460
commit
d1d4155c88
4 files changed
+50
-33
No files matched your search
+6
@@ -14,6 +14,7 @@ import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.constants.EnumCategoryType;
|
||||
import noppes.npcs.controllers.CategoryManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -63,6 +64,11 @@ public final class AbilityCategoryMovePacket extends AbstractPacket {
|
||||
String itemName = ByteBufUtils.readString(in);
|
||||
int cat = in.readInt();
|
||||
|
||||
// Validate target category exists (0 = Uncategorized is always valid)
|
||||
CategoryManager cm = CategorySavePacket.getManager(type);
|
||||
if (cm == null) return;
|
||||
if (cat != CategoryManager.UNCATEGORIZED_ID && cm.getCategory(cat) == null) return;
|
||||
|
||||
switch (type) {
|
||||
case EnumCategoryType.ABILITY:
|
||||
AbilityController.Instance.moveCustomAbilityToCategory(itemName, cat);
|
||||
|
||||
+6
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import kamkeel.npcs.controllers.AbilityController;
|
||||
import noppes.npcs.constants.EnumCategoryType;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.CategoryManager;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.LinkedItemController;
|
||||
|
||||
@@ -65,6 +66,11 @@ public final class CategoryMoveItemPacket extends AbstractPacket {
|
||||
int item = in.readInt();
|
||||
int cat = in.readInt();
|
||||
|
||||
// Validate target category exists (0 = Uncategorized is always valid)
|
||||
CategoryManager cm = CategorySavePacket.getManager(type);
|
||||
if (cm == null) return;
|
||||
if (cat != CategoryManager.UNCATEGORIZED_ID && cm.getCategory(cat) == null) return;
|
||||
|
||||
switch (type) {
|
||||
case EnumCategoryType.EFFECT: CustomEffectController.getInstance().moveItemToCategory(item, cat); break;
|
||||
case EnumCategoryType.ANIMATION: AnimationController.getInstance().moveItemToCategory(item, cat); break;
|
||||
|
||||
@@ -764,44 +764,47 @@ public class GuiAbilityDirectory extends GuiDirectoryCategorized
|
||||
GL11.glEnable(GL11.GL_SCISSOR_TEST);
|
||||
setScissorClip(previewX, previewY, previewW, previewH);
|
||||
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef(npcScreenX, npcScreenY, 500F);
|
||||
GL11.glScalef(-renderZoom, renderZoom, renderZoom);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(CAMERA_PITCH, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glTranslatef(0.0F, npc.yOffset, 0.0F);
|
||||
RenderManager.instance.playerViewY = 180F;
|
||||
ClientEventHandler.renderingEntityInGUI = true;
|
||||
|
||||
// Render NPC at its position delta
|
||||
try {
|
||||
RenderManager.instance.renderEntityWithPosYaw(npc, npcDeltaX, npcDeltaY, npcDeltaZ, 0.0F, partialTicks);
|
||||
} catch (Exception ignored) {}
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
// Render preview entities
|
||||
renderPreviewEntities(partialTicks);
|
||||
GL11.glTranslatef(npcScreenX, npcScreenY, 500F);
|
||||
GL11.glScalef(-renderZoom, renderZoom, renderZoom);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(CAMERA_PITCH, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
// Render telegraph
|
||||
renderPreviewTelegraph(partialTicks);
|
||||
GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
ClientEventHandler.renderingEntityInGUI = false;
|
||||
GL11.glPopMatrix();
|
||||
GL11.glTranslatef(0.0F, npc.yOffset, 0.0F);
|
||||
RenderManager.instance.playerViewY = 180F;
|
||||
ClientEventHandler.renderingEntityInGUI = true;
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
// Render NPC at its position delta
|
||||
try {
|
||||
RenderManager.instance.renderEntityWithPosYaw(npc, npcDeltaX, npcDeltaY, npcDeltaZ, 0.0F, partialTicks);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
// Render preview entities
|
||||
renderPreviewEntities(partialTicks);
|
||||
|
||||
// Render telegraph
|
||||
renderPreviewTelegraph(partialTicks);
|
||||
|
||||
ClientEventHandler.renderingEntityInGUI = false;
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
} finally {
|
||||
ClientEventHandler.renderingEntityInGUI = false;
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
||||
@@ -771,7 +771,7 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
|
||||
if (subgui instanceof SubGuiEditText) {
|
||||
if (!((SubGuiEditText) subgui).cancelled && selectedCatId > 0) {
|
||||
String name = ((SubGuiEditText) subgui).text;
|
||||
if (name != null && !name.isEmpty() && !catData.containsKey(name)) {
|
||||
if (name != null && !name.isEmpty() && !name.equals(prevCatName) && !catData.containsKey(name)) {
|
||||
Category cat = new Category(selectedCatId, name);
|
||||
onSaveCategory(cat);
|
||||
catData.remove(prevCatName);
|
||||
@@ -779,6 +779,8 @@ public abstract class GuiDirectoryCategorized extends GuiDirectory
|
||||
prevCatName = name;
|
||||
}
|
||||
}
|
||||
// Restore category selection to current name (handles validation failure)
|
||||
catScroll.setSelected(prevCatName);
|
||||
}
|
||||
if (subgui instanceof SubGuiCategoryMoveConfirm) {
|
||||
SubGuiCategoryMoveConfirm confirm = (SubGuiCategoryMoveConfirm) subgui;
|
||||
|
||||
Reference in new issue
Block a user