From 50cb0150aaf1fcba737a22faf00e3355ae1872b8 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Sun, 12 Jun 2022 04:42:33 -0500 Subject: [PATCH] Reverted GuiCreationScreen changes. --- .../client/gui/model/GuiCreationScreen.java | 338 +++++++++--------- 1 file changed, 171 insertions(+), 167 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 9c8f5c36d..7364fdabc 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -39,87 +39,87 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol public HashMap> data = new HashMap>(); private List list; private final String[] ignoredTags = {"CanBreakDoors", "Bred", "PlayerCreated", "Tame", "HasReproduced"}; - + private GuiNpcButton prev,next; private GuiScreen parent; - + private HashMap mapped = new HashMap(); - + public GuiCreationScreen(GuiScreen parent, EntityCustomNpc npc){ super(npc); this.parent = parent; - Map mapping = EntityList.stringToClassMapping; - for(Object name : mapping.keySet()){ - Class c = (Class) mapping.get(name); - try { - if(!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())){ - if(RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity) - data.put(name.toString(),c.asSubclass(EntityLivingBase.class)); - } + Map mapping = EntityList.stringToClassMapping; + for(Object name : mapping.keySet()){ + Class c = (Class) mapping.get(name); + try { + if(!EntityCustomNpc.class.isAssignableFrom(c) && EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[] {World.class}) != null && !Modifier.isAbstract(c.getModifiers())){ + if(RenderManager.instance.getEntityClassRenderObject(c) instanceof RendererLivingEntity) + data.put(name.toString(),c.asSubclass(EntityLivingBase.class)); + } } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { } - } + } list = new ArrayList(data.keySet()); Collections.sort(list,String.CASE_INSENSITIVE_ORDER); } - @Override - public void initGui() { - EntityLivingBase entity = (EntityLivingBase) playerdata.getEntity(npc); - xOffset = entity == null?0:50; - super.initGui(); + @Override + public void initGui() { + EntityLivingBase entity = (EntityLivingBase) playerdata.getEntity(npc); + xOffset = entity == null?0:50; + super.initGui(); - String title = "CustomNPC"; - if(entity != null) - title = (String) EntityList.classToStringMapping.get(playerdata.getEntityClass()); - this.addButton(new GuiNpcButton(1, guiLeft + 140, guiTop, 100, 20, title)); + String title = "CustomNPC"; + if(entity != null) + title = (String) EntityList.classToStringMapping.get(playerdata.getEntityClass()); + this.addButton(new GuiNpcButton(1, guiLeft + 140, guiTop, 100, 20, title)); + + this.addButton(prev = new GuiNpcButton(0, guiLeft + 118, guiTop, 20, 20, "<")); + this.addButton(next = new GuiNpcButton(2, guiLeft + 242, guiTop, 20, 20, ">")); + prev.enabled = getCurrentEntityIndex() >= 0; + next.enabled = getCurrentEntityIndex() < list.size() - 1; + + if(entity == null){ + showPlayerButtons(); + } + else if(PixelmonHelper.isPixelmon(entity)){ + showPixelmonMenu(entity); + } + else{ + showEntityButtons(entity); + } + } - this.addButton(prev = new GuiNpcButton(0, guiLeft + 118, guiTop, 20, 20, "<")); - this.addButton(next = new GuiNpcButton(2, guiLeft + 242, guiTop, 20, 20, ">")); - prev.enabled = getCurrentEntityIndex() >= 0; - next.enabled = getCurrentEntityIndex() < list.size() - 1; - - if(entity == null){ - showPlayerButtons(); - } - else if(PixelmonHelper.isPixelmon(entity)){ - showPixelmonMenu(entity); - } - else{ - showEntityButtons(entity); - } - } - private void showPlayerButtons() { int y = guiTop ; - - addButton(new GuiNpcButton(8, guiLeft + 4, y += 22, 96, 20, "model.scale")); - addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addButton(new GuiNpcButton(8, guiLeft + 4, y += 22, 96, 20, "model.scale")); + + addButton(new GuiNpcButton(4, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(1, "Head", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addButton(new GuiNpcButton(5, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(2, "Body", guiLeft, y + 5, 0xFFFFFF)); - - addButton(new GuiNpcButton(6, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + + addButton(new GuiNpcButton(6, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(3, "Arms", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(7, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); + addButton(new GuiNpcButton(7, guiLeft + 50, y += 22, 50, 20, "selectServer.edit")); addLabel(new GuiNpcLabel(4, "Legs", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Steve","Alex"}, this.npc.display.modelType/2)); + addButton(new GuiNpcButton(250, guiLeft + 50, y += 22, 50, 20, new String[]{"Default","Steve64","Alex"}, this.npc.display.modelType)); addLabel(new GuiNpcLabel(250, "Model", guiLeft, y + 5, 0xFFFFFF)); - addButton(new GuiNpcButton(44, guiLeft + 310, guiTop + 14, 80, 20, "Save Model")); - addButton(new GuiNpcButton(45, guiLeft + 310, guiTop + 36, 80, 20, "Load Model")); + addButton(new GuiNpcButton(44, guiLeft + 310, guiTop + 14, 80, 20, "Save Model")); + addButton(new GuiNpcButton(45, guiLeft + 310, guiTop + 36, 80, 20, "Load Model")); - } + } - private void showPixelmonMenu(EntityLivingBase entity) { + private void showPixelmonMenu(EntityLivingBase entity) { GuiCustomScroll scroll = new GuiCustomScroll(this, 0); scroll.setSize(120, 200); scroll.guiLeft = guiLeft; @@ -148,7 +148,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol if(name.equals("Age")){ i++; addLabel(new GuiNpcLabel(0, "Child", guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(30, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"},entity.isChild()?1:0)); + addButton(new GuiNpcButton(30, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"},entity.isChild()?1:0)); } else if(base.getId() == 1){ byte b = ((NBTTagByte)base).func_150290_f(); @@ -158,9 +158,9 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol b = playerdata.extra.getByte(name); i++; addLabel(new GuiNpcLabel(100 + i, name, guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(100 + i, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"}, b)); + addButton(new GuiNpcButton(100 + i, guiLeft + 80, y + i * 22, 50, 20, new String[]{"gui.no","gui.yes"}, b)); - mapped.put(i, name); + mapped.put(i, name); } } if(EntityList.getEntityString(entity).equals("doggystyle.Dog")){ @@ -173,7 +173,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol } i++; addLabel(new GuiNpcLabel(201, "Breed", guiLeft, y + 5 + i * 22, 0xFFFFFF)); - addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed)); + addButton(new GuiNpcButton(201, guiLeft + 80, y + i * 22, 50, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"}, breed)); } } private boolean isIgnored(String tag){ @@ -202,157 +202,161 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol } private int getCurrentEntityIndex(){ - return list.indexOf(EntityList.classToStringMapping.get(playerdata.getEntityClass())); - } + return list.indexOf(EntityList.classToStringMapping.get(playerdata.getEntityClass())); + } - @Override - protected void actionPerformed(GuiButton btn) { - super.actionPerformed(btn); - GuiNpcButton button = (GuiNpcButton) btn; - if(button.id == 0){ - int index = getCurrentEntityIndex(); - if(!prev.enabled) - return; - index--; - try{ - if(index < 0){ - playerdata.setEntityClass(null); - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - else{ - playerdata.setEntityClass(data.get(list.get(index))); + @Override + protected void actionPerformed(GuiButton btn) { + super.actionPerformed(btn); + GuiNpcButton button = (GuiNpcButton) btn; + if(button.id == 0){ + int index = getCurrentEntityIndex(); + if(!prev.enabled) + return; + index--; + try{ + if(index < 0){ + playerdata.setEntityClass(null); + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + else{ + playerdata.setEntityClass(data.get(list.get(index))); - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity != null){ - RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); - npc.display.texture = NPCRendererHelper.getTexture(render,entity); - } - } - //npc.display.glowTexture = ""; + EntityLivingBase entity = playerdata.getEntity(npc); + if(entity != null){ + RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); + npc.display.texture = NPCRendererHelper.getTexture(render,entity); + } + } + //npc.display.glowTexture = ""; npc.display.skinOverlayData.overlayList.remove(0); npc.textureLocation = null; npc.updateHitbox(); - } - catch(Exception ex){ - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - initGui(); - } - if(button.id == 2){ - int index = getCurrentEntityIndex(); - if(!next.enabled) - return; - index++; - playerdata.setEntityClass(data.get(list.get(index))); + } + catch(Exception ex){ + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + initGui(); + } + if(button.id == 2){ + int index = getCurrentEntityIndex(); + if(!next.enabled) + return; + index++; + playerdata.setEntityClass(data.get(list.get(index))); - updateTexture(); + updateTexture(); - initGui(); - } + initGui(); + } - if(button.id == 1){ - this.mc.displayGuiScreen(new GuiEntitySelection(this, playerdata, npc)); - } + if(button.id == 1){ + this.mc.displayGuiScreen(new GuiEntitySelection(this, playerdata, npc)); + } - if(button.id == 4){ - this.mc.displayGuiScreen(new GuiModelHead(this, npc)); - } - if(button.id == 5){ - this.mc.displayGuiScreen(new GuiModelBody(this, npc)); - } - if(button.id == 6){ - this.mc.displayGuiScreen(new GuiModelArms(this, npc)); - } - if(button.id == 7){ - this.mc.displayGuiScreen(new GuiModelLegs(this, npc)); - } + if(button.id == 4){ + this.mc.displayGuiScreen(new GuiModelHead(this, npc)); + } + if(button.id == 5){ + this.mc.displayGuiScreen(new GuiModelBody(this, npc)); + } + if(button.id == 6){ + this.mc.displayGuiScreen(new GuiModelArms(this, npc)); + } + if(button.id == 7){ + this.mc.displayGuiScreen(new GuiModelLegs(this, npc)); + } - // New Button for Changing Models + // New Button for Changing Models // URL Swapper if(button.id == 250){ - npc.display.modelType = button.displayString.equals("Alex") ? 2 : 1; - - if(npc.display.modelType == 1){ + if(npc.display.modelType == 0){ if (npc.display.skinType == 2){ npc.display.skinType = 3; } - } else { + npc.display.modelType = 1; + } + else if(npc.display.modelType == 1){ + npc.display.modelType = 2; + } + else { if (npc.display.skinType == 3){ npc.display.skinType = 2; } + npc.display.modelType = 0; } npc.textureLocation = null; } - if(button.id == 8){ - this.mc.displayGuiScreen(new GuiModelScale(this, playerdata, npc)); - } - if(button.id == 30){ - playerdata.extra.setInteger("Age",button.getValue() == 1?-24000:0); - playerdata.clearEntity(); - } - - if(button.id == 44){ - this.mc.displayGuiScreen(new GuiPresetSave(this, playerdata)); - } + if(button.id == 8){ + this.mc.displayGuiScreen(new GuiModelScale(this, playerdata, npc)); + } + if(button.id == 30){ + playerdata.extra.setInteger("Age",button.getValue() == 1?-24000:0); + playerdata.clearEntity(); + } - if(button.id == 45){ - this.mc.displayGuiScreen(new GuiPresetSelection(this, playerdata)); - } - if(button.id >= 100 && button.id < 200){ - String name = mapped.get(button.id - 100); - if(name != null){ - playerdata.extra.setBoolean(name, button.getValue() == 1); - playerdata.clearEntity(); - } - } - if(button.id == 201){ + if(button.id == 44){ + this.mc.displayGuiScreen(new GuiPresetSave(this, playerdata)); + } + + if(button.id == 45){ + this.mc.displayGuiScreen(new GuiPresetSelection(this, playerdata)); + } + if(button.id >= 100 && button.id < 200){ + String name = mapped.get(button.id - 100); + if(name != null){ + playerdata.extra.setBoolean(name, button.getValue() == 1); + playerdata.clearEntity(); + } + } + if(button.id == 201){ try { - EntityLivingBase entity = playerdata.getEntity(npc); + EntityLivingBase entity = playerdata.getEntity(npc); Method method = entity.getClass().getMethod("setBreedID", int.class); method.invoke(entity, ((GuiNpcButton)button).getValue()); NBTTagCompound comp = new NBTTagCompound(); entity.writeEntityToNBT(comp); playerdata.extra.setString("EntityData21", comp.getString("EntityData21")); - playerdata.clearEntity(); - updateTexture(); + playerdata.clearEntity(); + updateTexture(); } catch (Exception e) { - + } - } - } - - private void updateTexture(){ - try{ - EntityLivingBase entity = playerdata.getEntity(npc); - if(entity != null){ - RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); - npc.display.texture = NPCRendererHelper.getTexture(render,entity); - } - else{ - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - //npc.display.glowTexture = ""; - npc.display.skinOverlayData.overlayList.remove(0); - npc.textureLocation = null; - npc.updateHitbox(); } - catch(Exception ex){ - npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; - } - } - - @Override - public void close(){ - Client.sendData(EnumPacketServer.ModelDataSave, playerdata.writeToNBT()); - displayGuiScreen(parent); - } + } + + private void updateTexture(){ + try{ + EntityLivingBase entity = playerdata.getEntity(npc); + if(entity != null){ + RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); + npc.display.texture = NPCRendererHelper.getTexture(render,entity); + } + else{ + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + //npc.display.glowTexture = ""; + npc.display.skinOverlayData.overlayList.remove(0); + npc.textureLocation = null; + npc.updateHitbox(); + } + catch(Exception ex){ + npc.display.texture = "customnpcs:textures/entity/humanmale/Steve.png"; + } + } + + @Override + public void close(){ + Client.sendData(EnumPacketServer.ModelDataSave, playerdata.writeToNBT()); + displayGuiScreen(parent); + } @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { playerdata.clearEntity(); playerdata.extra.setString("Name", scroll.getSelected()); - + EntityLivingBase entity = playerdata.getEntity(npc); RendererLivingEntity render = (RendererLivingEntity) RenderManager.instance.getEntityRenderObject(entity); npc.display.texture = NPCRendererHelper.getTexture(render, entity);