mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 17:23:07 +00:00
Natural Spawn Entries:
-Added GUI options for new natural spawn attributes. -Added 4 more entity options -Fixed natural spawning not working at night
This commit is contained in:
1 parent
55b21de050
commit
dd700c677b
5 files changed
+221
-17
No files matched your search
@@ -0,0 +1,76 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.controllers.data.SpawnData;
|
||||
|
||||
public class SubGuiSpawningOptions extends SubGuiInterface implements ITextfieldListener {
|
||||
private SpawnData data;
|
||||
|
||||
public SubGuiSpawningOptions(SpawnData data){
|
||||
this.data = data;
|
||||
setBackground("menubg.png");
|
||||
xSize = 216;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
int y = guiTop - 15;
|
||||
|
||||
addButton(new GuiNpcButtonYesNo(10, guiLeft + 120, y += 22, data.animalSpawning));
|
||||
addLabel(new GuiNpcLabel(10, "spawning.animalSpawning", guiLeft + 4, y + 5));
|
||||
|
||||
addButton(new GuiNpcButtonYesNo(11, guiLeft + 120, y += 22, data.monsterSpawning));
|
||||
addLabel(new GuiNpcLabel(11, "spawning.monsterSpawning", guiLeft + 4, y + 5));
|
||||
|
||||
addButton(new GuiNpcButtonYesNo(12, guiLeft + 120, y += 22, data.liquidSpawning));
|
||||
addLabel(new GuiNpcLabel(12, "spawning.liquidSpawning", guiLeft + 4, y + 5));
|
||||
|
||||
addButton(new GuiNpcButtonYesNo(13, guiLeft + 120, y += 22, data.airSpawning));
|
||||
addLabel(new GuiNpcLabel(13, "spawning.airSpawning", guiLeft + 4, y + 5));
|
||||
|
||||
addTextField(new GuiNpcTextField(14, this, guiLeft + 120, y += 22, 40, 20, String.valueOf(data.spawnHeightMin)));
|
||||
addLabel(new GuiNpcLabel(14, "spawning.minHeight", guiLeft + 4, y + 5));
|
||||
addTextField(new GuiNpcTextField(15, this, guiLeft + 120, y += 22, 40, 20, String.valueOf(data.spawnHeightMax)));
|
||||
addLabel(new GuiNpcLabel(15, "spawning.maxHeight", guiLeft + 4, y + 5));
|
||||
getTextField(14).integersOnly = true;
|
||||
getTextField(14).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
|
||||
getTextField(15).integersOnly = true;
|
||||
getTextField(15).setMinMaxDefault(-Integer.MAX_VALUE, Integer.MAX_VALUE, 0);
|
||||
|
||||
addButton(new GuiNpcButton(100, guiLeft + 154, guiTop + 192, 60, 20, "gui.done"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
|
||||
if (button.id == 10) {
|
||||
data.animalSpawning = button.getValue() == 1;
|
||||
}
|
||||
if (button.id == 11) {
|
||||
data.monsterSpawning = button.getValue() == 1;
|
||||
}
|
||||
if (button.id == 12) {
|
||||
data.liquidSpawning = button.getValue() == 1;
|
||||
}
|
||||
if (button.id == 13) {
|
||||
data.airSpawning = button.getValue() == 1;
|
||||
}
|
||||
if (button.id == 100) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
if (textfield.id == 14) {
|
||||
data.spawnHeightMin = textfield.getInteger();
|
||||
}
|
||||
if (textfield.id == 15) {
|
||||
data.spawnHeightMax = textfield.getInteger();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerSelector;
|
||||
import noppes.npcs.client.gui.SubGuiNpcBiomes;
|
||||
import noppes.npcs.client.gui.SubGuiSpawningOptions;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
@@ -31,6 +32,7 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
|
||||
private HashMap<String, Integer> data = new HashMap<String, Integer>();
|
||||
|
||||
private SpawnData spawn = new SpawnData();
|
||||
private int slotSelected;
|
||||
|
||||
public GuiNpcNaturalSpawns(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
@@ -60,15 +62,34 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
|
||||
addLabel(new GuiNpcLabel(1,"gui.title", guiLeft + 4, guiTop + 8));
|
||||
addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, guiLeft + 60, guiTop + 3, 140, 20, spawn.name));
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"spawning.biomes", guiLeft + 4, guiTop + 30));
|
||||
addButton(new GuiNpcButton(3, guiLeft + 120, guiTop + 25, 50, 20, "selectServer.edit"));
|
||||
int y = guiTop + 30;
|
||||
addLabel(new GuiNpcLabel(3,"spawning.biomes", guiLeft + 4, y));
|
||||
addButton(new GuiNpcButton(3, guiLeft + 120, y - 5, 50, 20, "selectServer.edit"));
|
||||
|
||||
addSlider(new GuiNpcSlider(this, 4, guiLeft + 4, guiTop + 47, 180, 20, (float)spawn.itemWeight / 100));
|
||||
addLabel(new GuiNpcLabel(4,"spawning.options", guiLeft + 4, y += 22));
|
||||
addButton(new GuiNpcButton(4, guiLeft + 120, y - 5, 50, 20, "selectServer.edit"));
|
||||
|
||||
int y = guiTop + 70;
|
||||
this.addButton(new GuiNpcButton(25, guiLeft + 14, y,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(5, "1:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 36, y, 170, 20, getTitle(spawn.compound1)));
|
||||
addSlider(new GuiNpcSlider(this, 5, guiLeft + 4, y += 17, 180, 20, (float)spawn.itemWeight / 100));
|
||||
|
||||
this.addButton(new GuiNpcButton(25, guiLeft + 14, y += 23,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(6, "1:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(6, guiLeft + 36, y, 170, 20, getTitle(spawn.compound1)));
|
||||
|
||||
this.addButton(new GuiNpcButton(26, guiLeft + 14, y += 22,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(7, "2:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(7, guiLeft + 36, y, 170, 20, getTitle(spawn.compound2)));
|
||||
|
||||
this.addButton(new GuiNpcButton(27, guiLeft + 14, y += 22,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(8, "3:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(8, guiLeft + 36, y, 170, 20, getTitle(spawn.compound3)));
|
||||
|
||||
this.addButton(new GuiNpcButton(28, guiLeft + 14, y += 22,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(9, "4:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(9, guiLeft + 36, y, 170, 20, getTitle(spawn.compound4)));
|
||||
|
||||
this.addButton(new GuiNpcButton(29, guiLeft + 14, y += 22,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(10, "5:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 36, y, 170, 20, getTitle(spawn.compound5)));
|
||||
}
|
||||
private String getTitle(NBTTagCompound compound) {
|
||||
if(compound != null && compound.hasKey("ClonedName"))
|
||||
@@ -101,13 +122,35 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
|
||||
if(id == 3){
|
||||
setSubGui(new SubGuiNpcBiomes(spawn));
|
||||
}
|
||||
if(id == 5){
|
||||
if(id == 4){
|
||||
setSubGui(new SubGuiSpawningOptions(spawn));
|
||||
}
|
||||
|
||||
if(id >= 6 && id <= 10){
|
||||
slotSelected = id - 5;
|
||||
setSubGui(new GuiNpcMobSpawnerSelector());
|
||||
}
|
||||
|
||||
if(id == 25){
|
||||
spawn.compound1 = new NBTTagCompound();
|
||||
initGui();
|
||||
}
|
||||
if(id == 26){
|
||||
spawn.compound2 = new NBTTagCompound();
|
||||
initGui();
|
||||
}
|
||||
if(id == 27){
|
||||
spawn.compound3 = new NBTTagCompound();
|
||||
initGui();
|
||||
}
|
||||
if(id == 28){
|
||||
spawn.compound4 = new NBTTagCompound();
|
||||
initGui();
|
||||
}
|
||||
if(id == 29){
|
||||
spawn.compound5 = new NBTTagCompound();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +207,25 @@ public class GuiNpcNaturalSpawns extends GuiNPCInterface2 implements IGuiData, I
|
||||
if(gui instanceof GuiNpcMobSpawnerSelector){
|
||||
GuiNpcMobSpawnerSelector selector = (GuiNpcMobSpawnerSelector) gui;
|
||||
NBTTagCompound compound = selector.getCompound();
|
||||
if(compound != null)
|
||||
spawn.compound1 = compound;
|
||||
if (compound != null) {
|
||||
switch (slotSelected) {
|
||||
case 1:
|
||||
spawn.compound1 = compound;
|
||||
break;
|
||||
case 2:
|
||||
spawn.compound2 = compound;
|
||||
break;
|
||||
case 3:
|
||||
spawn.compound3 = compound;
|
||||
break;
|
||||
case 4:
|
||||
spawn.compound4 = compound;
|
||||
break;
|
||||
case 5:
|
||||
spawn.compound5 = compound;
|
||||
break;
|
||||
}
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user