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
14 changes: 4 additions & 10 deletions src/main/java/noppes/mpm/ModelPartData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";

Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
227 changes: 226 additions & 1 deletion src/main/java/noppes/mpm/client/gui/GuiCreationParts.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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(){
Expand Down Expand Up @@ -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<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
Loading