Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/kamkeel/MorePlayerModelsPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/noppes/mpm/client/gui/GuiCreationParts.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand All @@ -12,6 +13,7 @@
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;
Expand Down Expand Up @@ -51,6 +53,9 @@ public GuiCreationParts(){
if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HORNS)){
partList.add(new GuiPartHorns());
}
if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HALO)){
partList.add(new GuiPartHalo());
}
if(ClientPermController.hasPermission(MorePlayerModelsPermissions.PARTS_HAIR)){
partList.add(new GuiPartHair());
}
Expand Down Expand Up @@ -317,6 +322,68 @@ public int initGui(){
return y;
}
}
class GuiPartHalo extends GuiPart{
public GuiPartHalo() {
super(EnumParts.HALO);
types = new String[]{"gui.none", "gui.halo.base", "gui.halo.base_textured", "gui.halo.thin", "gui.halo.thin_textured"};
noPlayerOptions();
}

@Override
public int initGui() {
int y = super.initGui();
if(data != null && data.type >= 2){
GuiCreationParts.this.addSlider(new GuiNpcSlider(new FakeGui(this::actionPerformed), 49, guiLeft + 145, y, StatCollector.translateToLocal("gui.halo.width"), (data.pattern & 0xF) / 15F));
GuiCreationParts.this.addSlider(new GuiNpcSlider(new FakeGui(this::actionPerformed), 50, guiLeft + 145, y + 24, StatCollector.translateToLocal("gui.halo.elevation"), (data.pattern >> 4 & 0xF) / 15F));
}
return y;
}

@Override
protected void actionPerformed(GuiButton btn) {
switch (btn.id) {
case 49:
data.pattern = (byte) ((data.pattern & 0xF0) | (int) (((GuiNpcSlider) btn).sliderValue * 15));
break;
case 50:
data.pattern = (byte) ((data.pattern & 0xF) | (int) (((GuiNpcSlider) btn).sliderValue * 15) << 4);
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.pattern = 0b111 << 4 | 0b111;
data.setType(i - 1);
}
GuiCreationParts.this.initGui();
break;
default:
super.actionPerformed(btn);
break;
}
}

class FakeGui extends GuiScreen implements ISliderListener {
private Consumer<GuiNpcSlider> listener;
private FakeGui(Consumer<GuiNpcSlider> 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);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/noppes/mpm/client/model/ModelMPM.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
151 changes: 151 additions & 0 deletions src/main/java/noppes/mpm/client/model/part/head/ModelHalo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
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 net.minecraft.util.ResourceLocation;
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 static final ResourceLocation haloTexture = new ResourceLocation("moreplayermodels", "textures/halo/halo.png");
private AbstractClientPlayer entity;
private boolean applyTexture;
private boolean thinHalo;
private byte haloWidth;
private byte haloElevation;

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((float)entity.worldObj.getTotalWorldTime(), 0.0F, 1.0F, 0.0F);
float f = (float)entity.ticksExisted + ClientEventHandler.partialTicks;
float 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);
}

if(!applyTexture) {
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;
GL11.glDisable(GL11.GL_LIGHTING);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);

super.render(f5);

OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevX, prevY);
GL11.glEnable(GL11.GL_LIGHTING);

if(!applyTexture) {
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;

thinHalo = config.type > 1;
haloBase.isHidden = thinHalo;
haloThin.isHidden = !thinHalo;
haloWidth = (byte) (config.pattern & 0xF);
haloElevation = (byte) ((config.pattern >> 4) & 0xF);

applyTexture = config.type % 2 == 1;
location = haloTexture;
}
}
2 changes: 2 additions & 0 deletions src/main/java/noppes/mpm/config/ConfigPerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/noppes/mpm/constants/EnumParts.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum EnumParts {
BREASTS("breasts"),
PARTICLES("particles"),
ARMS("arms"),
CAPE("cape");
CAPE("cape"),
HALO("halo");

public String name;

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/assets/moreplayermodels/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ 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

animation.sleep=Sleep
animation.crawl=Crawl
Expand All @@ -55,6 +61,7 @@ scale.shared=Shared

part.ears=Ears
part.horns=Horns
part.halo=Halo
part.hair=Hair
part.mohawk=Mohawk
part.snout=Snout
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.