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..9866215 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.copy()); 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; } @@ -80,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 cf94f38..d3a5e87 100644 --- a/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java +++ b/src/main/java/noppes/mpm/client/gui/GuiCreationParts.java @@ -2,16 +2,20 @@ 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; 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 +55,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()); } @@ -193,7 +200,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(){ @@ -317,6 +324,224 @@ public int initGui(){ return y; } } + class GuiPartHalo extends GuiPart{ + private int page = 0; + 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.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; + 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; + } + + @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.setRotationY(data, ((GuiNpcSlider) btn).sliderValue); + break; + case 52: + ModelHalo.setRotationY(data, 0.5F); + GuiCreationParts.this.getSlider(51).sliderValue = ModelHalo.getRotationY(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 58: + page = ((GuiNpcButton)btn).getValue(); + GuiCreationParts.this.initGui(); + 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 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) + playerdata.removePart(part); + else { + data = playerdata.getOrCreatePart(part); + data.setCustomResource(""); + data.playerTexture = false; + data.customData = new NBTTagCompound(); + data.setType(i - 1); + } + GuiCreationParts.this.initGui(); + break; + default: + super.actionPerformed(btn); + break; + } + } + + class FakeGui extends GuiScreen implements ISliderListener { + private final 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/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(); + } + } 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..41279b3 --- /dev/null +++ b/src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java @@ -0,0 +1,321 @@ +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.nbt.NBTTagCompound; +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 haloOffsetX; + public float haloOffsetY; + public float haloOffsetZ; + public float haloRotationX; + public float haloRotationY; + public float haloRotationZ; + public float spinSpeed; + public float floatSpeed; + public float floatDistance; + public byte haloMaterial; + public byte type; + public NBTTagCompound customData; + + 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; + } + + public void translateHalo() { + float f1 = 0; + if(floatSpeed > 0.01 && floatDistance > 0.01) { + float f = (float) entity.ticksExisted + ClientEventHandler.partialTicks; + 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 = haloOffsetY - 0.5F; + GL11.glTranslatef((haloOffsetX - 0.5F) * 2, -elevation, (haloOffsetZ - 0.5F) * 2); + } + + 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.ticksExisted * 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) { + GL11.glTranslatef(0F, -0.45F, 0F); + float width = haloWidth * 0.8F - 0.4F; + 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; + spinSpeed = getSpinSpeed(config); + floatSpeed = getFloatingSpeed(config); + floatDistance = getFloatingDistance(config); + haloBase.isHidden = thinHalo; + haloThin.isHidden = !thinHalo; + haloWidth = getWidth(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; + haloMaterial = getMaterial(config); + customData = (NBTTagCompound) config.customData.copy(); + } + + 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 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 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; + } + + 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 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; + } + + 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; + } + + 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..b430a10 100644 --- a/src/main/resources/assets/moreplayermodels/lang/en_US.lang +++ b/src/main/resources/assets/moreplayermodels/lang/en_US.lang @@ -27,6 +27,7 @@ gui.show=Show gui.left=Left gui.right=Right gui.both=Both +gui.page=Page gui.default=Default gui.color=Color gui.remove=Remove @@ -37,6 +38,25 @@ 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.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 +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 @@ -55,6 +75,7 @@ scale.shared=Shared part.ears=Ears part.horns=Horns +part.halo=Halo part.hair=Hair part.mohawk=Mohawk part.snout=Snout