From 1c83b742702fa58dd9d737eecdf98eb61e05bcc1 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Fri, 13 Feb 2026 13:15:52 +0100 Subject: [PATCH 1/8] Added halo part --- .../kamkeel/MorePlayerModelsPermissions.java | 1 + src/main/java/noppes/mpm/ModelPartData.java | 5 +- .../mpm/client/gui/GuiCreationParts.java | 134 ++++++++++ .../noppes/mpm/client/model/ModelMPM.java | 4 + .../mpm/client/model/part/head/ModelHalo.java | 228 ++++++++++++++++++ .../java/noppes/mpm/config/ConfigPerm.java | 2 + .../java/noppes/mpm/constants/EnumParts.java | 3 +- .../assets/moreplayermodels/lang/en_US.lang | 14 ++ 8 files changed, 389 insertions(+), 2 deletions(-) create mode 100644 src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java diff --git a/src/main/java/kamkeel/MorePlayerModelsPermissions.java b/src/main/java/kamkeel/MorePlayerModelsPermissions.java index e8a8867..624ede8 100644 --- a/src/main/java/kamkeel/MorePlayerModelsPermissions.java +++ b/src/main/java/kamkeel/MorePlayerModelsPermissions.java @@ -32,6 +32,7 @@ public class MorePlayerModelsPermissions { public static final Permission PARTS_FIN = new Permission("mpm.parts.fin", ConfigPerm.PARTS_FIN); public static final Permission PARTS_HAIR = new Permission("mpm.parts.hair", ConfigPerm.PARTS_HAIR); public static final Permission PARTS_HORNS = new Permission("mpm.parts.horns", ConfigPerm.PARTS_HORNS); + public static final Permission PARTS_HALO = new Permission("mpm.parts.halo", ConfigPerm.PARTS_HALO); public static final Permission PARTS_LEGS = new Permission("mpm.parts.legs", ConfigPerm.PARTS_LEGS); public static final Permission PARTS_MOHAWK = new Permission("mpm.parts.mohawk", ConfigPerm.PARTS_MOHAWK); public static final Permission PARTS_PARTICLES = new Permission("mpm.parts.particles", ConfigPerm.PARTS_PARTICLES); diff --git a/src/main/java/noppes/mpm/ModelPartData.java b/src/main/java/noppes/mpm/ModelPartData.java index aa79ab9..66b4c16 100644 --- a/src/main/java/noppes/mpm/ModelPartData.java +++ b/src/main/java/noppes/mpm/ModelPartData.java @@ -13,6 +13,7 @@ public class ModelPartData { public byte pattern = 0; public boolean playerTexture; public String name; + public NBTTagCompound customData = new NBTTagCompound(); private ResourceLocation location; private String custom = ""; @@ -28,8 +29,9 @@ public NBTTagCompound writeToNBT(){ compound.setInteger("Color", color); compound.setBoolean("PlayerTexture", playerTexture); compound.setByte("Pattern", pattern); - if(!custom.equals("")) + if(!custom.isEmpty()) compound.setString("CustomTexture", custom); + compound.setTag("CustomData", customData); return compound; } @@ -40,6 +42,7 @@ public void readFromNBT(NBTTagCompound compound){ playerTexture = compound.getBoolean("PlayerTexture"); pattern = compound.getByte("Pattern"); custom = compound.getString("CustomTexture"); + customData = compound.getCompoundTag("CustomData"); location = null; } diff --git a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java index cf94f38..74abfb8 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java +++ b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java @@ -2,16 +2,19 @@ import kamkeel.MorePlayerModelsPermissions; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.StatCollector; import noppes.mpm.ModelData; import noppes.mpm.ModelPartData; import noppes.mpm.client.controller.ClientPermController; import noppes.mpm.client.gui.util.*; +import noppes.mpm.client.model.part.head.ModelHalo; import noppes.mpm.constants.EnumParts; import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.function.Consumer; public class GuiCreationParts extends GuiCreationScreenInterface implements ITextfieldListener, ICustomScrollListener{ private GuiCustomScroll scroll; @@ -51,6 +54,9 @@ public GuiCreationParts(){ if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HORNS)){ partList.add(new GuiPartHorns()); } + if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HALO)){ + partList.add(new GuiPartHalo().setTypes(new String[]{"gui.none", "gui.halo.base", "gui.halo.thin"})); + } if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HAIR)){ partList.add(new GuiPartHair()); } @@ -317,6 +323,134 @@ public int initGui(){ return y; } } + class GuiPartHalo extends GuiPart{ + public GuiPartHalo() { + super(EnumParts.HALO); + noPlayerOptions(); + } + + @Override + public int initGui() { + data = playerdata.getPartData(part); + int y = guiTop + 50; + if(data == null || !data.playerTexture || !noPlayerTypes) { + GuiCreationParts.this.addLabel(new GuiNpcLabel(20, "gui.type", guiLeft + 102, y + 5, 0xFFFFFF)); + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(20, guiLeft + 145, y, 100, 20, types, data == null ? 0 : data.type + 1)); + y += 24; + } + if(data != null && !data.playerTexture && !noPlayerTextures) { + GuiCreationParts.this.addLabel(new GuiNpcLabel(23, "gui.color", guiLeft + 102, y + 5, 0xFFFFFF)); + GuiCreationParts.this.addButton(new GuiColorButton(23, guiLeft + 150, y, data.color)); + y += 24; + } + if(data != null && data.type >= 1){ + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(57, guiLeft + 215, y - 25, 60, 20, new String[]{"Off", "Lit", "Solid"}, ModelHalo.getMaterial(data))); + int btnWidth = fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.halo.reset")) + 10; + + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 132, y, 100, 20, ModelHalo.getWidth(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.width")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(50, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 51, guiLeft + 132, y, 100, 20, ModelHalo.getElevation(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.elevation")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(52, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 53, guiLeft + 132, y, 100, 20, ModelHalo.getRotationX(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationX")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(54, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 55, guiLeft + 132, y, 100, 20, ModelHalo.getRotationZ(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationZ")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(56, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + GuiCreationParts.this.addLabel(new GuiNpcLabel(22, "gui.pattern", guiLeft + 102, y + 5, 0xFFFFFF)); + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(22, guiLeft + 155, y, 100, 20, new String[]{"gui.halo.float_spin","gui.halo.float","gui.halo.spin","gui.halo.none"}, data.pattern)); + y += 23; + } + return y; + } + + @Override + protected void actionPerformed(GuiButton btn) { + switch (btn.id) { + case 49: + ModelHalo.setWidth(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 50: + ModelHalo.setWidth(data, 0.5F); + GuiCreationParts.this.getSlider(49).sliderValue = ModelHalo.getWidth(data); + break; + case 51: + ModelHalo.setElevation(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 52: + ModelHalo.setElevation(data, 0.5F); + GuiCreationParts.this.getSlider(51).sliderValue = ModelHalo.getElevation(data); + break; + case 53: + ModelHalo.setRotationX(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 54: + ModelHalo.setRotationX(data, 0.5F); + GuiCreationParts.this.getSlider(53).sliderValue = ModelHalo.getRotationX(data); + break; + case 55: + ModelHalo.setRotationZ(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 56: + ModelHalo.setRotationZ(data, 0.5F); + GuiCreationParts.this.getSlider(55).sliderValue = ModelHalo.getRotationZ(data); + break; + case 57: + ModelHalo.setMaterial(data, (byte) ((GuiNpcButton) btn).getValue()); + break; + case 20: + int i = ((GuiNpcButton) btn).getValue(); + if (i == 0 && canBeDeleted) + playerdata.removePart(part); + else { + data = playerdata.getOrCreatePart(part); + data.setCustomResource(""); + data.playerTexture = false; + ModelHalo.setWidth(data, 0.5F); + ModelHalo.setElevation(data, 0.5F); + ModelHalo.setRotationX(data, 0.5F); + ModelHalo.setRotationZ(data, 0.5F); + data.setType(i - 1); + } + GuiCreationParts.this.initGui(); + break; + default: + super.actionPerformed(btn); + break; + } + } + + class FakeGui extends GuiScreen implements ISliderListener { + private Consumer listener; + private FakeGui(Consumer listener) { + this.listener = listener; + } + @Override + public void mouseDragged(GuiNpcSlider guiNpcSlider) { + listener.accept(guiNpcSlider); + } + + @Override + public void mousePressed(GuiNpcSlider guiNpcSlider) {} + + @Override + public void mouseReleased(GuiNpcSlider guiNpcSlider) {} + } + } class GuiPartHair extends GuiPart{ public GuiPartHair() { super(EnumParts.HAIR); diff --git a/src/main/java/noppes/mpm/client/model/ModelMPM.java b/src/main/java/noppes/mpm/client/model/ModelMPM.java index c7970bf..346afd6 100644 --- a/src/main/java/noppes/mpm/client/model/ModelMPM.java +++ b/src/main/java/noppes/mpm/client/model/ModelMPM.java @@ -42,6 +42,7 @@ public class ModelMPM extends ModelBiped{ private ModelPartInterface fin; private ModelPartInterface skirt; private ModelPartInterface horns; + private ModelPartInterface halo; private ModelPartInterface clawsR; private ModelPartInterface clawsL; private ModelCape cape; @@ -189,6 +190,7 @@ public ModelMPM(float par1, boolean alex) { // Completed this.bipedHead.addChild(snout = new ModelSnout(this)); this.bipedHead.addChild(horns = new ModelHorns(this)); + this.bipedHead.addChild(halo = new ModelHalo(this)); // Completed tail = new ModelTail(this); @@ -306,6 +308,7 @@ public ModelMPM(float par1, int alexArms) { // Completed this.bipedHead.addChild(snout = new ModelSnout(this)); this.bipedHead.addChild(horns = new ModelHorns(this)); + this.bipedHead.addChild(halo = new ModelHalo(this)); // Completed tail = new ModelTail(this); @@ -333,6 +336,7 @@ public void setPlayerData(ModelData data, EntityLivingBase entity){ clawsR.setData(data, player); skirt.setData(data, player); horns.setData(data, player); + halo.setData(data, player); } breasts.setData(data, player); legs.setData(data, player); diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java new file mode 100644 index 0000000..a5e246d --- /dev/null +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -0,0 +1,228 @@ +package noppes.mpm.client.model.part.head; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.util.MathHelper; +import noppes.mpm.ModelData; +import noppes.mpm.ModelPartData; +import noppes.mpm.client.ClientEventHandler; +import noppes.mpm.client.model.ModelMPM; +import noppes.mpm.client.model.ModelPartInterface; +import noppes.mpm.constants.EnumParts; +import org.lwjgl.opengl.GL11; + +public class ModelHalo extends ModelPartInterface { + private AbstractClientPlayer entity; + private boolean thinHalo; + public float haloWidth; + public float haloElevation; + public float haloRotationX; + public float haloRotationZ; + public boolean shouldFloat; + public boolean shouldRotate; + public byte haloMaterial; + public byte type; + + private final ModelRenderer haloBase; + private final ModelRenderer haloThin; + public final ModelRenderer[] haloSegments; + public final ModelRenderer[] haloSegmentsThin; + + public ModelHalo(ModelMPM base) { + super(base); + this.textureWidth = 81; + this.textureHeight = 34; + + haloBase = new ModelRenderer(base, 0, 34); + haloBase.setTextureSize((int) textureWidth, (int) textureHeight); + haloBase.setRotationPoint(0.0F, 0.0F, 0.0F); + haloBase.addBox(-4.0F, -8.0F, -4.0F, 0, 0, 0, 0.0F); + + haloThin = new ModelRenderer(base, 0, 34); + haloThin.setTextureSize((int) textureWidth, (int) textureHeight); + haloThin.setRotationPoint(0.0F, 0.0F, 0.0F); + haloThin.addBox(-4.0F, -8.0F, -4.0F, 0, 0, 0, 0.0F); + + haloSegments = new ModelRenderer[12]; + + for(int i = 0; i < haloSegments.length; i++) { + haloSegments[i] = new ModelRenderer(base, 0, 32); + haloSegments[i].setTextureSize((int) textureWidth, (int) textureHeight); + if(i == 0) { + haloSegments[i].setRotationPoint(0.0F, -9.0F, -3.85F); + } else { + haloSegments[i].setRotationPoint(2F, 0F, 0F); + } + haloSegments[i].addBox(0F, -1F, 0F, 2, 1, 1, 0F); + if(i == 0) { + setRotateAngle(haloSegments[i], 0F, (float) (-Math.PI / haloSegments.length), 0F); + } else { + setRotateAngle(haloSegments[i], 0F, (float) (-2D * Math.PI / haloSegments.length), 0F); + haloSegments[i - 1].addChild(haloSegments[i]); + } + } + haloBase.addChild(haloSegments[0]); + + haloSegmentsThin = new ModelRenderer[48]; + + for(int i = 0; i < haloSegmentsThin.length; i++) { + haloSegmentsThin[i] = new ModelRenderer(base, 0, 32); + haloSegmentsThin[i].setTextureSize((int) textureWidth, (int) textureHeight); + haloSegmentsThin[i].setRotationPoint(0F, -9.0F, 0F); + haloSegmentsThin[i].addBox((float) (40F/Math.PI), -1F, -1, 1, 1, 2, 0F); + setRotateAngle(haloSegmentsThin[i], 0F, i * (float) (-2D * Math.PI / haloSegmentsThin.length), 0F); + haloThin.addChild(haloSegmentsThin[i]); + } + + addChild(haloBase); + addChild(haloThin); + } + + @Override + public void setData(ModelData data, AbstractClientPlayer entity) { + super.setData(data, entity); + this.entity = entity; + } + + @Override + public void render(float f5) { + if (this.isHidden || !this.showModel) + return; + GL11.glPushMatrix(); + GL11.glRotatef(haloRotationX, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(haloRotationZ, 0.0F, 0.0F, 1.0F); + if(shouldRotate) { + GL11.glRotatef((float) entity.worldObj.getTotalWorldTime(), 0.0F, 1.0F, 0.0F); + } + float f1 = 0; + if(shouldFloat) { + float f = (float) entity.ticksExisted + ClientEventHandler.partialTicks; + f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; + f1 = f1 * f1 + f1; + } + GL11.glTranslatef(0.0F, -0.2F + f1 * 0.05F, 0.0F); + if (entity.isSneaking()) { + GL11.glTranslatef(0.0F, 0.2F, 0.0F); + } + + GL11.glDisable(GL11.GL_TEXTURE_2D); + if(thinHalo) { + float width = haloWidth * 0.05F - 0.4F; + float elevation = haloElevation * 0.05F - 0.4F; + GL11.glTranslatef(0F, -0.4F - elevation, 0F); + GL11.glScalef(0.7F + width, 0.3F, 0.7F + width); + } + + float prevX = OpenGlHelper.lastBrightnessX; + float prevY = OpenGlHelper.lastBrightnessY; + if(haloMaterial <= 1) { + GL11.glDisable(GL11.GL_LIGHTING); + } + if(haloMaterial == 1) { + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F); + } + + super.render(f5); + + if(haloMaterial == 1) { + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevX, prevY); + } + if(haloMaterial <= 1) { + GL11.glEnable(GL11.GL_LIGHTING); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + + GL11.glPopMatrix(); + } + + private void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } + + @Override + public void initData(ModelData data) { + ModelPartData config = data.getPartData(EnumParts.HALO); + if(config == null) { + isHidden = true; + return; + } + isHidden = false; + this.color = config.color; + + type = config.type; + thinHalo = type == 1; + shouldFloat = config.pattern <= 1; + shouldRotate = config.pattern % 2 == 0; + haloBase.isHidden = thinHalo; + haloThin.isHidden = !thinHalo; + haloWidth = getWidth(config) * 14F; + haloElevation = getElevation(config) * 14F; + haloRotationX = getRotationX(config) * 180 - 90; + haloRotationZ = getRotationZ(config) * 180 - 90; + haloMaterial = getMaterial(config); + } + + public static float getWidth(ModelPartData data) { + return data.customData.hasKey("width") ? data.customData.getFloat("width") : 0.5F; + } + + public static void setWidth(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("width", value); + } else { + data.customData.removeTag("width"); + } + } + + public static float getElevation(ModelPartData data) { + return data.customData.hasKey("elevation") ? data.customData.getFloat("elevation") : 0.5F; + } + + public static void setElevation(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("elevation", value); + } else { + data.customData.removeTag("elevation"); + } + } + + public static float getRotationX(ModelPartData data) { + return data.customData.hasKey("rotX") ? data.customData.getFloat("rotX") : 0.5F; + } + + public static void setRotationX(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("rotX", value); + } else { + data.customData.removeTag("rotX"); + } + } + + public static float getRotationZ(ModelPartData data) { + return data.customData.hasKey("rotZ") ? data.customData.getFloat("rotZ") : 0.5F; + } + + public static void setRotationZ(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("rotZ", value); + } else { + data.customData.removeTag("rotZ"); + } + } + + public static byte getMaterial(ModelPartData data) { + return data.customData.hasKey("material") ? data.customData.getByte("material") : 0; + } + + public static void setMaterial(ModelPartData data, byte material) { + if(material != 0) { + data.customData.setByte("material", material); + } else { + data.customData.removeTag("material"); + } + } +} diff --git a/src/main/java/noppes/mpm/config/ConfigPerm.java b/src/main/java/noppes/mpm/config/ConfigPerm.java index 39db916..c0b4fd8 100644 --- a/src/main/java/noppes/mpm/config/ConfigPerm.java +++ b/src/main/java/noppes/mpm/config/ConfigPerm.java @@ -31,6 +31,7 @@ public class ConfigPerm { public static boolean PARTS_FIN; public static boolean PARTS_HAIR; public static boolean PARTS_HORNS; + public static boolean PARTS_HALO; public static boolean PARTS_LEGS; public static boolean PARTS_MOHAWK; public static boolean PARTS_PARTICLES; @@ -89,6 +90,7 @@ public static void init(File configFile) { PARTS_FIN = permConfig.get(PART, "PARTS_FIN", true).getBoolean(); PARTS_HAIR = permConfig.get(PART, "PARTS_HAIR", true).getBoolean(); PARTS_HORNS = permConfig.get(PART, "PARTS_HORNS", true).getBoolean(); + PARTS_HALO = permConfig.get(PART, "PARTS_HALO", true).getBoolean(); PARTS_LEGS = permConfig.get(PART, "PARTS_LEGS", true).getBoolean(); PARTS_MOHAWK = permConfig.get(PART, "PARTS_MOHAWK", true).getBoolean(); PARTS_PARTICLES = permConfig.get(PART, "PARTS_PARTICLES", true).getBoolean(); diff --git a/src/main/java/noppes/mpm/constants/EnumParts.java b/src/main/java/noppes/mpm/constants/EnumParts.java index 9e8a1e0..fcaa876 100644 --- a/src/main/java/noppes/mpm/constants/EnumParts.java +++ b/src/main/java/noppes/mpm/constants/EnumParts.java @@ -18,7 +18,8 @@ public enum EnumParts { BREASTS("breasts"), PARTICLES("particles"), ARMS("arms"), - CAPE("cape"); + CAPE("cape"), + HALO("halo"); public String name; diff --git a/src/main/resources/assets/moreplayermodels/lang/en_US.lang b/src/main/resources/assets/moreplayermodels/lang/en_US.lang index 38af897..3435996 100644 --- a/src/main/resources/assets/moreplayermodels/lang/en_US.lang +++ b/src/main/resources/assets/moreplayermodels/lang/en_US.lang @@ -37,6 +37,19 @@ gui.resettoplayer=Reset To Player gui.player=Player gui.new=New gui.hide=Hide +gui.halo.base=Base +gui.halo.base_textured=Textured +gui.halo.thin=Thin +gui.halo.thin_textured=Thin Textured +gui.halo.width=Width +gui.halo.elevation=Elevation +gui.halo.rotationX=X Rotation +gui.halo.rotationZ=Z Rotation +gui.halo.reset=Reset +gui.halo.float_spin=Float & Spin +gui.halo.float=Float +gui.halo.spin=Spin +gui.halo.none=None animation.sleep=Sleep animation.crawl=Crawl @@ -55,6 +68,7 @@ scale.shared=Shared part.ears=Ears part.horns=Horns +part.halo=Halo part.hair=Hair part.mohawk=Mohawk part.snout=Snout From 3d56ec3cc893105ac5631ccb51d58866000273d5 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Tue, 24 Feb 2026 23:15:55 +0100 Subject: [PATCH 2/8] Removed halo translation on sneaking --- src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java index a5e246d..d1d5d16 100644 --- a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -102,9 +102,6 @@ public void render(float f5) { f1 = f1 * f1 + f1; } GL11.glTranslatef(0.0F, -0.2F + f1 * 0.05F, 0.0F); - if (entity.isSneaking()) { - GL11.glTranslatef(0.0F, 0.2F, 0.0F); - } GL11.glDisable(GL11.GL_TEXTURE_2D); if(thinHalo) { From 72c1dfe8d59901e0575ba4c178485f48f37925d0 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Wed, 25 Feb 2026 17:43:25 +0100 Subject: [PATCH 3/8] Fixed sync issue due to comparing same object --- src/main/java/noppes/mpm/ModelPartData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/mpm/ModelPartData.java b/src/main/java/noppes/mpm/ModelPartData.java index 66b4c16..65aef28 100644 --- a/src/main/java/noppes/mpm/ModelPartData.java +++ b/src/main/java/noppes/mpm/ModelPartData.java @@ -31,7 +31,7 @@ public NBTTagCompound writeToNBT(){ compound.setByte("Pattern", pattern); if(!custom.isEmpty()) compound.setString("CustomTexture", custom); - compound.setTag("CustomData", customData); + compound.setTag("CustomData", customData.copy()); return compound; } From 7173a542a9f5f53a6019f418259655d676582195 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Thu, 26 Feb 2026 21:59:23 +0100 Subject: [PATCH 4/8] Added more halo configuration --- .../mpm/client/gui/GuiCreationParts.java | 132 +++++++++++++----- .../mpm/client/model/part/head/ModelHalo.java | 107 +++++++++++--- .../assets/moreplayermodels/lang/en_US.lang | 6 + 3 files changed, 191 insertions(+), 54 deletions(-) diff --git a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java index 74abfb8..2ab27a4 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java +++ b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java @@ -324,6 +324,7 @@ public int initGui(){ } } class GuiPartHalo extends GuiPart{ + private int page = 0; public GuiPartHalo() { super(EnumParts.HALO); noPlayerOptions(); @@ -343,37 +344,66 @@ public int initGui() { GuiCreationParts.this.addButton(new GuiColorButton(23, guiLeft + 150, y, data.color)); y += 24; } - if(data != null && data.type >= 1){ - GuiCreationParts.this.addButton(new GuiButtonBiDirectional(57, guiLeft + 215, y - 25, 60, 20, new String[]{"Off", "Lit", "Solid"}, ModelHalo.getMaterial(data))); + if(data != null && data.type >= 1) { int btnWidth = fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.halo.reset")) + 10; - - GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 132, y, 100, 20, ModelHalo.getWidth(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.width")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(50, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 51, guiLeft + 132, y, 100, 20, ModelHalo.getElevation(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.elevation")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(52, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 53, guiLeft + 132, y, 100, 20, ModelHalo.getRotationX(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.rotationX")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(54, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 55, guiLeft + 132, y, 100, 20, ModelHalo.getRotationZ(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.rotationZ")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(56, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - GuiCreationParts.this.addLabel(new GuiNpcLabel(22, "gui.pattern", guiLeft + 102, y + 5, 0xFFFFFF)); - GuiCreationParts.this.addButton(new GuiButtonBiDirectional(22, guiLeft + 155, y, 100, 20, new String[]{"gui.halo.float_spin","gui.halo.float","gui.halo.spin","gui.halo.none"}, data.pattern)); - y += 23; + if (page == 0) { + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(57, guiLeft + 215, y - 25, 60, 20, new String[]{"Off", "Lit", "Solid"}, ModelHalo.getMaterial(data))); + + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 112, y, 120, 20, ModelHalo.getWidth(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.width")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(50, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 53, guiLeft + 112, y, 120, 20, ModelHalo.getRotationX(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationX")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(54, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 51, guiLeft + 112, y, 120, 20, ModelHalo.getRotationY(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationY")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(52, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 55, guiLeft + 112, y, 120, 20, ModelHalo.getRotationZ(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationZ")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(56, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + GuiCreationParts.this.addButton(new GuiNpcButton(58, guiLeft + 190, y, 80, 20, "gui.next")); + y += 23; + } else { + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 60, guiLeft + 112, y, 120, 20, ModelHalo.getElevation(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.elevation")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(61, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 62, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingSpeed(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.floating_speed")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(63, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 64, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingDistance(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.floating_distance")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(65, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + // Avoid 66 id, it closes gui + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 67, guiLeft + 112, y, 120, 20, ModelHalo.getSpinSpeed(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.spin_speed")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(68, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + GuiCreationParts.this.addButton(new GuiNpcButton(59, guiLeft + 105, y, 80, 20, "gui.previous")); + y += 23; + } } return y; } @@ -389,11 +419,11 @@ protected void actionPerformed(GuiButton btn) { GuiCreationParts.this.getSlider(49).sliderValue = ModelHalo.getWidth(data); break; case 51: - ModelHalo.setElevation(data, ((GuiNpcSlider) btn).sliderValue); + ModelHalo.setRotationY(data, ((GuiNpcSlider) btn).sliderValue); break; case 52: - ModelHalo.setElevation(data, 0.5F); - GuiCreationParts.this.getSlider(51).sliderValue = ModelHalo.getElevation(data); + ModelHalo.setRotationY(data, 0.5F); + GuiCreationParts.this.getSlider(51).sliderValue = ModelHalo.getRotationY(data); break; case 53: ModelHalo.setRotationX(data, ((GuiNpcSlider) btn).sliderValue); @@ -412,6 +442,42 @@ protected void actionPerformed(GuiButton btn) { case 57: ModelHalo.setMaterial(data, (byte) ((GuiNpcButton) btn).getValue()); break; + case 58: + page = 1; + GuiCreationParts.this.initGui(); + break; + case 59: + page = 0; + GuiCreationParts.this.initGui(); + break; + case 60: + ModelHalo.setElevation(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 61: + ModelHalo.setElevation(data, 0.5F); + GuiCreationParts.this.getSlider(60).sliderValue = ModelHalo.getElevation(data); + break; + case 62: + ModelHalo.setFloatingSpeed(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 63: + ModelHalo.setFloatingSpeed(data, 0.5F); + GuiCreationParts.this.getSlider(62).sliderValue = ModelHalo.getFloatingSpeed(data); + break; + case 64: + ModelHalo.setFloatingDistance(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 65: + ModelHalo.setFloatingDistance(data, 0.5F); + GuiCreationParts.this.getSlider(64).sliderValue = ModelHalo.getFloatingDistance(data); + break; + case 67: + ModelHalo.setSpinSpeed(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 68: + ModelHalo.setSpinSpeed(data, 0.5F); + GuiCreationParts.this.getSlider(67).sliderValue = ModelHalo.getSpinSpeed(data); + break; case 20: int i = ((GuiNpcButton) btn).getValue(); if (i == 0 && canBeDeleted) diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java index d1d5d16..b646bfc 100644 --- a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -18,9 +18,11 @@ public class ModelHalo extends ModelPartInterface { public float haloWidth; public float haloElevation; public float haloRotationX; + public float haloRotationY; public float haloRotationZ; - public boolean shouldFloat; - public boolean shouldRotate; + public float spinSpeed; + public float floatSpeed; + public float floatDistance; public byte haloMaterial; public byte type; @@ -85,29 +87,42 @@ public void setData(ModelData data, AbstractClientPlayer entity) { this.entity = entity; } - @Override - public void render(float f5) { - if (this.isHidden || !this.showModel) - return; - GL11.glPushMatrix(); - GL11.glRotatef(haloRotationX, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(haloRotationZ, 0.0F, 0.0F, 1.0F); - if(shouldRotate) { - GL11.glRotatef((float) entity.worldObj.getTotalWorldTime(), 0.0F, 1.0F, 0.0F); - } + public void translateHalo() { float f1 = 0; - if(shouldFloat) { + if(floatSpeed > 0.01 && floatDistance > 0.01) { float f = (float) entity.ticksExisted + ClientEventHandler.partialTicks; - f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; + f1 = MathHelper.sin(f * 0.4F * floatSpeed * floatSpeed) / 2.0F + 0.5F; f1 = f1 * f1 + f1; + f1 *= floatDistance * floatDistance * 4; } GL11.glTranslatef(0.0F, -0.2F + f1 * 0.05F, 0.0F); + float elevation = haloElevation - 0.5F; + GL11.glTranslatef(0F, -elevation, 0F); + } + + public void rotateHalo() { + GL11.glRotatef(haloRotationX, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(haloRotationY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(haloRotationZ, 0.0F, 0.0F, 1.0F); + if(spinSpeed >= 0.01) { + GL11.glRotatef((float) entity.worldObj.getTotalWorldTime() * spinSpeed * spinSpeed * 4, 0.0F, 1.0F, 0.0F); + } + } + + @Override + public void render(float f5) { + if (this.isHidden || !this.showModel) + return; + GL11.glPushMatrix(); + + rotateHalo(); + translateHalo(); + GL11.glDisable(GL11.GL_TEXTURE_2D); if(thinHalo) { - float width = haloWidth * 0.05F - 0.4F; - float elevation = haloElevation * 0.05F - 0.4F; - GL11.glTranslatef(0F, -0.4F - elevation, 0F); + GL11.glTranslatef(0F, -0.45F, 0F); + float width = haloWidth * 0.8F - 0.4F; GL11.glScalef(0.7F + width, 0.3F, 0.7F + width); } @@ -152,13 +167,15 @@ public void initData(ModelData data) { type = config.type; thinHalo = type == 1; - shouldFloat = config.pattern <= 1; - shouldRotate = config.pattern % 2 == 0; + spinSpeed = getSpinSpeed(config); + floatSpeed = getFloatingSpeed(config); + floatDistance = getFloatingDistance(config); haloBase.isHidden = thinHalo; haloThin.isHidden = !thinHalo; - haloWidth = getWidth(config) * 14F; - haloElevation = getElevation(config) * 14F; + haloWidth = getWidth(config); + haloElevation = getElevation(config); haloRotationX = getRotationX(config) * 180 - 90; + haloRotationY = getRotationY(config) * 360 - 180; haloRotationZ = getRotationZ(config) * 180 - 90; haloMaterial = getMaterial(config); } @@ -199,6 +216,18 @@ public static void setRotationX(ModelPartData data, float value) { } } + public static float getRotationY(ModelPartData data) { + return data.customData.hasKey("rotY") ? data.customData.getFloat("rotY") : 0.5F; + } + + public static void setRotationY(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("rotY", value); + } else { + data.customData.removeTag("rotY"); + } + } + public static float getRotationZ(ModelPartData data) { return data.customData.hasKey("rotZ") ? data.customData.getFloat("rotZ") : 0.5F; } @@ -211,6 +240,42 @@ public static void setRotationZ(ModelPartData data, float value) { } } + public static float getSpinSpeed(ModelPartData data) { + return data.customData.hasKey("spinSpeed") ? data.customData.getFloat("spinSpeed") : 0.5F; + } + + public static void setSpinSpeed(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("spinSpeed", value); + } else { + data.customData.removeTag("spinSpeed"); + } + } + + public static float getFloatingSpeed(ModelPartData data) { + return data.customData.hasKey("floatSpeed") ? data.customData.getFloat("floatSpeed") : 0.5F; + } + + public static void setFloatingSpeed(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("floatSpeed", value); + } else { + data.customData.removeTag("floatSpeed"); + } + } + + public static float getFloatingDistance(ModelPartData data) { + return data.customData.hasKey("floatDist") ? data.customData.getFloat("floatDist") : 0.5F; + } + + public static void setFloatingDistance(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("floatDist", value); + } else { + data.customData.removeTag("floatDist"); + } + } + public static byte getMaterial(ModelPartData data) { return data.customData.hasKey("material") ? data.customData.getByte("material") : 0; } diff --git a/src/main/resources/assets/moreplayermodels/lang/en_US.lang b/src/main/resources/assets/moreplayermodels/lang/en_US.lang index 3435996..c4dd077 100644 --- a/src/main/resources/assets/moreplayermodels/lang/en_US.lang +++ b/src/main/resources/assets/moreplayermodels/lang/en_US.lang @@ -27,6 +27,8 @@ gui.show=Show gui.left=Left gui.right=Right gui.both=Both +gui.next=Next +gui.previous=Previous gui.default=Default gui.color=Color gui.remove=Remove @@ -44,12 +46,16 @@ gui.halo.thin_textured=Thin Textured gui.halo.width=Width gui.halo.elevation=Elevation gui.halo.rotationX=X Rotation +gui.halo.rotationY=Y Rotation gui.halo.rotationZ=Z Rotation gui.halo.reset=Reset gui.halo.float_spin=Float & Spin gui.halo.float=Float gui.halo.spin=Spin gui.halo.none=None +gui.halo.floating_distance=Float Distance +gui.halo.floating_speed=Float Speed +gui.halo.spin_speed=Spin Speed animation.sleep=Sleep animation.crawl=Crawl From 53948777a13f2edad7d8bd67fb5a8520c35ff427 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Fri, 27 Feb 2026 11:23:59 +0100 Subject: [PATCH 5/8] Updated color gui to support other usages --- src/main/java/noppes/mpm/ModelPartData.java | 9 ----- .../mpm/client/gui/GuiCreationParts.java | 2 +- .../noppes/mpm/client/gui/GuiModelColor.java | 35 ++++++++++++------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main/java/noppes/mpm/ModelPartData.java b/src/main/java/noppes/mpm/ModelPartData.java index 65aef28..9866215 100644 --- a/src/main/java/noppes/mpm/ModelPartData.java +++ b/src/main/java/noppes/mpm/ModelPartData.java @@ -83,15 +83,6 @@ public String toString(){ return "Color: " + color + " Type: " + type; } - public String getColor() { - String str = Integer.toHexString(color); - - while(str.length() < 6) - str = "0" + str; - - return str; - } - public void setType(int type){ this.type = (byte) type; location = null; diff --git a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java index 2ab27a4..596f6fd 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java +++ b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java @@ -199,7 +199,7 @@ protected void actionPerformed(GuiButton btn) { GuiCreationParts.this.initGui(); } if(btn.id == 23){ - setSubGui(new GuiModelColor(GuiCreationParts.this, data)); + setSubGui(new GuiModelColor(GuiCreationParts.this, () -> data.color, v -> data.color = v)); } } public GuiPart noPlayerOptions(){ diff --git a/src/main/java/noppes/mpm/client/gui/GuiModelColor.java b/src/main/java/noppes/mpm/client/gui/GuiModelColor.java index 1b44d3e..c0c316a 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiModelColor.java +++ b/src/main/java/noppes/mpm/client/gui/GuiModelColor.java @@ -3,7 +3,6 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.IResource; import net.minecraft.util.ResourceLocation; -import noppes.mpm.ModelPartData; import noppes.mpm.client.gui.util.GuiNpcButton; import noppes.mpm.client.gui.util.GuiNpcTextField; import noppes.mpm.client.gui.util.ITextfieldListener; @@ -14,10 +13,10 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; +import java.util.function.Consumer; +import java.util.function.Supplier; public class GuiModelColor extends SubGuiInterface implements ITextfieldListener{ - - private GuiCreationScreenInterface parent; private final static ResourceLocation color = new ResourceLocation("moreplayermodels:textures/gui/color.png"); private final static ResourceLocation colorgui = new ResourceLocation("moreplayermodels:textures/gui/color_gui.png"); @@ -25,10 +24,12 @@ public class GuiModelColor extends SubGuiInterface implements ITextfieldListener private GuiNpcTextField textfield; - private ModelPartData data; - public GuiModelColor(GuiCreationScreenInterface parent, ModelPartData data){ + private final Supplier getter; + private final Consumer setter; + public GuiModelColor(GuiCreationScreenInterface parent, Supplier getter, Consumer setter){ this.parent = parent; - this.data = data; + this.getter = getter; + this.setter = setter; ySize = 230; closeOnEsc = false; background = colorgui; @@ -39,9 +40,9 @@ public void initGui() { super.initGui(); colorX = guiLeft + 4; colorY = guiTop + 50; - this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 35, guiTop + 25, 60, 20, data.getColor())); + this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 35, guiTop + 25, 60, 20, formatColor(getter.get()))); addButton(new GuiNpcButton(66, guiLeft + 107, guiTop + 8, 20, 20, "X")); - textfield.setTextColor(data.color); + textfield.setTextColor(getter.get()); } @Override @@ -60,7 +61,7 @@ public void keyTyped(char c, int i){ return; try{ int color = Integer.parseInt(textfield.getText(),16); - data.color = color; + setter.accept(color); textfield.setTextColor(color); } catch(NumberFormatException e){ @@ -88,9 +89,9 @@ public void mouseClicked(int i, int j, int k) { BufferedImage bufferedimage = ImageIO.read(stream = resource.getInputStream()); int color = bufferedimage.getRGB((i - guiLeft - 4) * 4, (j - guiTop - 50) * 4) & 16777215; if(color != 0){ - data.color = color; + setter.accept(color); textfield.setTextColor(color); - textfield.setText(data.getColor()); + textfield.setText(formatColor(getter.get())); } } catch (IOException e) { @@ -115,7 +116,17 @@ public void unFocused(GuiNpcTextField textfield) { catch(NumberFormatException e){ color = 0; } - data.color = color; + setter.accept(color); textfield.setTextColor(color); } + + public static String formatColor(int color) { + StringBuilder str = new StringBuilder(Integer.toHexString(color)); + + while(str.length() < 6) + str.insert(0, "0"); + + return str.toString(); + } + } From 5d370108bb07280ef744be4053e1c374cc9a8299 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Fri, 27 Feb 2026 11:24:18 +0100 Subject: [PATCH 6/8] Copied halo custom data to allow more extensions --- src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java index b646bfc..f2d4b14 100644 --- a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -3,6 +3,7 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import noppes.mpm.ModelData; import noppes.mpm.ModelPartData; @@ -25,6 +26,7 @@ public class ModelHalo extends ModelPartInterface { public float floatDistance; public byte haloMaterial; public byte type; + public NBTTagCompound customData; private final ModelRenderer haloBase; private final ModelRenderer haloThin; @@ -178,6 +180,7 @@ public void initData(ModelData data) { haloRotationY = getRotationY(config) * 360 - 180; haloRotationZ = getRotationZ(config) * 180 - 90; haloMaterial = getMaterial(config); + customData = (NBTTagCompound) config.customData.copy(); } public static float getWidth(ModelPartData data) { From 43491d97be396458e840ceb502992059b549fdb2 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Fri, 27 Feb 2026 17:16:01 +0100 Subject: [PATCH 7/8] Added offset configuration --- .../mpm/client/gui/GuiCreationParts.java | 173 ++++++++++-------- .../mpm/client/model/part/head/ModelHalo.java | 60 ++++-- .../assets/moreplayermodels/lang/en_US.lang | 7 +- 3 files changed, 147 insertions(+), 93 deletions(-) diff --git a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java index 596f6fd..d3a5e87 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java +++ b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java @@ -3,6 +3,7 @@ import kamkeel.MorePlayerModelsPermissions; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import noppes.mpm.ModelData; import noppes.mpm.ModelPartData; @@ -345,64 +346,81 @@ public int initGui() { y += 24; } if(data != null && data.type >= 1) { + GuiCreationParts.this.addLabel(new GuiNpcLabel(58, "gui.page", guiLeft + 102, guiTop + 55 + 48 + 4 * 23, 0xFFFFFF)); + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(58, guiLeft + 155, guiTop + 50 + 48 + 4 * 23, 80, 20, new String[] {"1", "2", "3"}, page)); + int btnWidth = fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.halo.reset")) + 10; - if (page == 0) { - GuiCreationParts.this.addButton(new GuiButtonBiDirectional(57, guiLeft + 215, y - 25, 60, 20, new String[]{"Off", "Lit", "Solid"}, ModelHalo.getMaterial(data))); - - GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 112, y, 120, 20, ModelHalo.getWidth(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.width")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(50, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 53, guiLeft + 112, y, 120, 20, ModelHalo.getRotationX(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.rotationX")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(54, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 51, guiLeft + 112, y, 120, 20, ModelHalo.getRotationY(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.rotationY")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(52, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 55, guiLeft + 112, y, 120, 20, ModelHalo.getRotationZ(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.rotationZ")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(56, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - GuiCreationParts.this.addButton(new GuiNpcButton(58, guiLeft + 190, y, 80, 20, "gui.next")); - y += 23; - } else { - GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 60, guiLeft + 112, y, 120, 20, ModelHalo.getElevation(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.elevation")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(61, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 62, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingSpeed(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.floating_speed")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(63, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 64, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingDistance(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.floating_distance")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(65, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - // Avoid 66 id, it closes gui - slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 67, guiLeft + 112, y, 120, 20, ModelHalo.getSpinSpeed(data)); - slider.setString(StatCollector.translateToLocal("gui.halo.spin_speed")); - GuiCreationParts.this.addSlider(slider); - GuiCreationParts.this.addButton(new GuiNpcButton(68, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); - y += 23; - - GuiCreationParts.this.addButton(new GuiNpcButton(59, guiLeft + 105, y, 80, 20, "gui.previous")); - y += 23; + switch (page) { + case 0: { + GuiCreationParts.this.addButton(new GuiButtonBiDirectional(57, guiLeft + 215, y - 25, 60, 20, new String[]{"Off", "Lit", "Solid"}, ModelHalo.getMaterial(data))); + + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 112, y, 120, 20, ModelHalo.getWidth(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.width")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(50, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 53, guiLeft + 112, y, 120, 20, ModelHalo.getRotationX(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationX")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(54, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 51, guiLeft + 112, y, 120, 20, ModelHalo.getRotationY(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationY")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(52, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 55, guiLeft + 112, y, 120, 20, ModelHalo.getRotationZ(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.rotationZ")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(56, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + break; + } + case 1: { + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 62, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingSpeed(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.floating_speed")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(63, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 64, guiLeft + 112, y, 120, 20, ModelHalo.getFloatingDistance(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.floating_distance")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(65, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + // Avoid 66 id, it closes gui + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 67, guiLeft + 112, y, 120, 20, ModelHalo.getSpinSpeed(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.spin_speed")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(68, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + break; + } + case 2: { + GuiNpcSlider slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 69, guiLeft + 112, y, 120, 20, ModelHalo.getOffsetX(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.offsetX")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(70, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 71, guiLeft + 112, y, 120, 20, ModelHalo.getOffsetY(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.offsetY")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(72, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + + slider = new GuiNpcSlider(new FakeGui(this::actionPerformed), 73, guiLeft + 112, y, 120, 20, ModelHalo.getOffsetZ(data)); + slider.setString(StatCollector.translateToLocal("gui.halo.offsetZ")); + GuiCreationParts.this.addSlider(slider); + GuiCreationParts.this.addButton(new GuiNpcButton(74, guiLeft + 132 + 105, y, btnWidth, 20, "gui.halo.reset")); + y += 23; + break; + } } } return y; @@ -443,20 +461,9 @@ protected void actionPerformed(GuiButton btn) { ModelHalo.setMaterial(data, (byte) ((GuiNpcButton) btn).getValue()); break; case 58: - page = 1; - GuiCreationParts.this.initGui(); - break; - case 59: - page = 0; + page = ((GuiNpcButton)btn).getValue(); GuiCreationParts.this.initGui(); break; - case 60: - ModelHalo.setElevation(data, ((GuiNpcSlider) btn).sliderValue); - break; - case 61: - ModelHalo.setElevation(data, 0.5F); - GuiCreationParts.this.getSlider(60).sliderValue = ModelHalo.getElevation(data); - break; case 62: ModelHalo.setFloatingSpeed(data, ((GuiNpcSlider) btn).sliderValue); break; @@ -478,6 +485,27 @@ protected void actionPerformed(GuiButton btn) { ModelHalo.setSpinSpeed(data, 0.5F); GuiCreationParts.this.getSlider(67).sliderValue = ModelHalo.getSpinSpeed(data); break; + case 69: + ModelHalo.setOffsetX(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 70: + ModelHalo.setOffsetX(data, 0.5F); + GuiCreationParts.this.getSlider(69).sliderValue = ModelHalo.getOffsetX(data); + break; + case 71: + ModelHalo.setOffsetY(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 72: + ModelHalo.setOffsetY(data, 0.5F); + GuiCreationParts.this.getSlider(71).sliderValue = ModelHalo.getOffsetY(data); + break; + case 73: + ModelHalo.setOffsetZ(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 74: + ModelHalo.setOffsetZ(data, 0.5F); + GuiCreationParts.this.getSlider(73).sliderValue = ModelHalo.getOffsetZ(data); + break; case 20: int i = ((GuiNpcButton) btn).getValue(); if (i == 0 && canBeDeleted) @@ -486,10 +514,7 @@ protected void actionPerformed(GuiButton btn) { data = playerdata.getOrCreatePart(part); data.setCustomResource(""); data.playerTexture = false; - ModelHalo.setWidth(data, 0.5F); - ModelHalo.setElevation(data, 0.5F); - ModelHalo.setRotationX(data, 0.5F); - ModelHalo.setRotationZ(data, 0.5F); + data.customData = new NBTTagCompound(); data.setType(i - 1); } GuiCreationParts.this.initGui(); @@ -501,7 +526,7 @@ protected void actionPerformed(GuiButton btn) { } class FakeGui extends GuiScreen implements ISliderListener { - private Consumer listener; + private final Consumer listener; private FakeGui(Consumer listener) { this.listener = listener; } diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java index f2d4b14..aa83fcc 100644 --- a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -17,7 +17,9 @@ public class ModelHalo extends ModelPartInterface { private AbstractClientPlayer entity; private boolean thinHalo; public float haloWidth; - public float haloElevation; + public float haloOffsetX; + public float haloOffsetY; + public float haloOffsetZ; public float haloRotationX; public float haloRotationY; public float haloRotationZ; @@ -99,8 +101,8 @@ public void translateHalo() { } GL11.glTranslatef(0.0F, -0.2F + f1 * 0.05F, 0.0F); - float elevation = haloElevation - 0.5F; - GL11.glTranslatef(0F, -elevation, 0F); + float elevation = haloOffsetY - 0.5F; + GL11.glTranslatef((haloOffsetX - 0.5F) * 2, -elevation, (haloOffsetZ - 0.5F) * 2); } public void rotateHalo() { @@ -175,7 +177,9 @@ public void initData(ModelData data) { haloBase.isHidden = thinHalo; haloThin.isHidden = !thinHalo; haloWidth = getWidth(config); - haloElevation = getElevation(config); + haloOffsetX = getOffsetX(config); + haloOffsetY = getOffsetY(config); + haloOffsetZ = getOffsetZ(config); haloRotationX = getRotationX(config) * 180 - 90; haloRotationY = getRotationY(config) * 360 - 180; haloRotationZ = getRotationZ(config) * 180 - 90; @@ -195,18 +199,6 @@ public static void setWidth(ModelPartData data, float value) { } } - public static float getElevation(ModelPartData data) { - return data.customData.hasKey("elevation") ? data.customData.getFloat("elevation") : 0.5F; - } - - public static void setElevation(ModelPartData data, float value) { - if(Math.abs(value - 0.5F) > 0.001) { - data.customData.setFloat("elevation", value); - } else { - data.customData.removeTag("elevation"); - } - } - public static float getRotationX(ModelPartData data) { return data.customData.hasKey("rotX") ? data.customData.getFloat("rotX") : 0.5F; } @@ -243,6 +235,42 @@ public static void setRotationZ(ModelPartData data, float value) { } } + public static float getOffsetX(ModelPartData data) { + return data.customData.hasKey("offsetX") ? data.customData.getFloat("offsetX") : 0.5F; + } + + public static void setOffsetX(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("offsetX", value); + } else { + data.customData.removeTag("offsetX"); + } + } + + public static float getOffsetY(ModelPartData data) { + return data.customData.hasKey("offsetY") ? data.customData.getFloat("offsetY") : 0.5F; + } + + public static void setOffsetY(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("offsetY", value); + } else { + data.customData.removeTag("offsetY"); + } + } + + public static float getOffsetZ(ModelPartData data) { + return data.customData.hasKey("offsetZ") ? data.customData.getFloat("offsetZ") : 0.5F; + } + + public static void setOffsetZ(ModelPartData data, float value) { + if(Math.abs(value - 0.5F) > 0.001) { + data.customData.setFloat("offsetZ", value); + } else { + data.customData.removeTag("offsetZ"); + } + } + public static float getSpinSpeed(ModelPartData data) { return data.customData.hasKey("spinSpeed") ? data.customData.getFloat("spinSpeed") : 0.5F; } diff --git a/src/main/resources/assets/moreplayermodels/lang/en_US.lang b/src/main/resources/assets/moreplayermodels/lang/en_US.lang index c4dd077..b430a10 100644 --- a/src/main/resources/assets/moreplayermodels/lang/en_US.lang +++ b/src/main/resources/assets/moreplayermodels/lang/en_US.lang @@ -27,8 +27,7 @@ gui.show=Show gui.left=Left gui.right=Right gui.both=Both -gui.next=Next -gui.previous=Previous +gui.page=Page gui.default=Default gui.color=Color gui.remove=Remove @@ -44,7 +43,9 @@ gui.halo.base_textured=Textured gui.halo.thin=Thin gui.halo.thin_textured=Thin Textured gui.halo.width=Width -gui.halo.elevation=Elevation +gui.halo.offsetX=X Offset +gui.halo.offsetY=Y Offset +gui.halo.offsetZ=Z Offset gui.halo.rotationX=X Rotation gui.halo.rotationY=Y Rotation gui.halo.rotationZ=Z Rotation From 74e37da7b2181668f0c0565ccc77540232cb4919 Mon Sep 17 00:00:00 2001 From: Toshayo Date: Fri, 27 Feb 2026 17:53:22 +0100 Subject: [PATCH 8/8] Fixed rotation based on world time, causing issues if it's altered by a mod --- src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java index aa83fcc..41279b3 100644 --- a/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -110,7 +110,7 @@ public void rotateHalo() { GL11.glRotatef(haloRotationY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(haloRotationZ, 0.0F, 0.0F, 1.0F); if(spinSpeed >= 0.01) { - GL11.glRotatef((float) entity.worldObj.getTotalWorldTime() * spinSpeed * spinSpeed * 4, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float) entity.ticksExisted * spinSpeed * spinSpeed * 4, 0.0F, 1.0F, 0.0F); } }