mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 01:02:19 +00:00
Tab Handling GUI
This commit is contained in:
1 parent
ad4033ed62
commit
65e29e42dd
29 files changed
+2961
-304
No files matched your search
@@ -2,7 +2,10 @@ package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneAllTagsPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneFolderCrudPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneFolderListPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneListPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneMovePacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneTagListPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.MobSpawnerPacket;
|
||||
@@ -16,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.controllers.ClientTagMapController;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
@@ -26,9 +30,16 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.client.gui.util.IClonerGui;
|
||||
import noppes.npcs.client.gui.util.ICustomScrollListener;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.client.gui.util.ISubGuiListener;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
import noppes.npcs.controllers.data.CloneFolder;
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.controllers.data.TagMap;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,51 +49,81 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData, ICustomScrollListener, ISubGuiListener, IClonerGui {
|
||||
|
||||
// ==================== STATIC STATE (persists across GUI opens, shared with fullscreen) ====================
|
||||
private static int sidebarMode = 0; // 0=Tabs, 1=Folders
|
||||
public static int activeTab = 1;
|
||||
public static String activeFolder = null;
|
||||
public static int showingClones = 0; // 0=Clones, 1=Entities, 2=Server, 3=Filters
|
||||
public static String search = "";
|
||||
public static String tagSearch = "";
|
||||
|
||||
public static HashMap<UUID, Tag> tags = new HashMap<>();
|
||||
public static HashMap<String, UUID> tagNames = new HashMap<>();
|
||||
public static HashSet<String> tagFilters = new HashSet<>();
|
||||
public static byte displayTags = 0;
|
||||
|
||||
// 0 - Any, 1 - All, 2 - Not Any, 3 - Not All
|
||||
public static byte filterCondition = 0;
|
||||
|
||||
public static byte ascending = 0;
|
||||
|
||||
// 0 - By Name, 1 - By Date
|
||||
public static byte sortType = 0;
|
||||
|
||||
// ==================== INSTANCE STATE ====================
|
||||
public TagMap tagMap;
|
||||
|
||||
private final GuiCustomScrollCloner scroll = new GuiCustomScrollCloner(this, 0);
|
||||
private final GuiCustomScroll filterScroll = new GuiCustomScroll(this, 1);
|
||||
|
||||
private int posX, posY, posZ;
|
||||
|
||||
public int posX, posY, posZ;
|
||||
private List<String> list;
|
||||
private List<String> rawList;
|
||||
private List<String> tagList;
|
||||
private List<String> folderNames = new ArrayList<>();
|
||||
|
||||
private static int showingClones = 0;
|
||||
|
||||
private static String search = "";
|
||||
private static String tagSearch = "";
|
||||
|
||||
private int activeTab = 1;
|
||||
// Scrollable folder side buttons (folders mode only)
|
||||
private HashMap<Integer, GuiMenuSideButton> folderSideButtons = new HashMap<>();
|
||||
private float folderScroll = 0;
|
||||
private float destFolderScroll = 0;
|
||||
|
||||
// ==================== CONSTRUCTOR ====================
|
||||
public GuiNpcMobSpawner(int i, int j, int k) {
|
||||
super();
|
||||
xSize = 354;
|
||||
posX = i;
|
||||
posY = j;
|
||||
posZ = k;
|
||||
|
||||
this.closeOnEsc = true;
|
||||
|
||||
closeOnEsc = true;
|
||||
xSize = 354;
|
||||
setBackground("menubg.png");
|
||||
PacketClient.sendClient(new CloneAllTagsPacket());
|
||||
loadFolderNames();
|
||||
}
|
||||
|
||||
private void loadFolderNames() {
|
||||
folderNames.clear();
|
||||
if (ClientCloneController.Instance != null) {
|
||||
for (CloneFolder folder : ClientCloneController.Instance.getFolderList()) {
|
||||
folderNames.add(folder.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== IClonerGui ====================
|
||||
@Override
|
||||
public int getShowingClones() {
|
||||
return showingClones;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<UUID, Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagMap getTagMap() {
|
||||
return tagMap;
|
||||
}
|
||||
|
||||
// ==================== INIT GUI ====================
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
guiTop += 10;
|
||||
@@ -92,6 +133,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
scroll.setSize(293, 188);
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 26;
|
||||
|
||||
filterScroll.clear();
|
||||
filterScroll.setSize(140, 166);
|
||||
filterScroll.guiLeft = guiLeft + 4;
|
||||
@@ -99,16 +141,18 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
filterScroll.multipleSelection = true;
|
||||
filterScroll.setSelectedList(tagFilters);
|
||||
|
||||
GuiMenuTopButton button;
|
||||
addTopButton(button = new GuiMenuTopButton(3, guiLeft + 4, guiTop - 17, "spawner.clones"));
|
||||
button.active = showingClones == 0;
|
||||
addTopButton(button = new GuiMenuTopButton(5, button, "gui.server"));
|
||||
button.active = showingClones == 2;
|
||||
addTopButton(button = new GuiMenuTopButton(4, button, "spawner.entities"));
|
||||
button.active = showingClones == 1;
|
||||
addTopButton(button = new GuiMenuTopButton(16, guiLeft + (xSize - 67), guiTop - 17, "gui.filters"));
|
||||
button.active = showingClones == 3;
|
||||
addTopButton(button = new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X"));
|
||||
// Top buttons
|
||||
GuiMenuTopButton btn;
|
||||
addTopButton(btn = new GuiMenuTopButton(3, guiLeft + 4, guiTop - 17, "spawner.clones"));
|
||||
btn.active = showingClones == 0;
|
||||
addTopButton(btn = new GuiMenuTopButton(5, btn, "gui.server"));
|
||||
btn.active = showingClones == 2;
|
||||
addTopButton(btn = new GuiMenuTopButton(4, btn, "spawner.entities"));
|
||||
btn.active = showingClones == 1;
|
||||
addTopButton(btn = new GuiMenuTopButton(16, guiLeft + (xSize - 82), guiTop - 17, "gui.filters"));
|
||||
btn.active = showingClones == 3;
|
||||
addTopButton(new GuiMenuTopButton(61, guiLeft + (xSize - 37), guiTop - 17, "+"));
|
||||
addTopButton(new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X"));
|
||||
|
||||
if (showingClones < 3) {
|
||||
addScroll(scroll);
|
||||
@@ -117,95 +161,136 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
addButton(new GuiNpcButton(2, guiLeft + 298, guiTop + 140, 52, 20, "spawner.mobspawner"));
|
||||
|
||||
if (showingClones == 0 || showingClones == 2) {
|
||||
|
||||
addSideButton(new GuiMenuSideButton(21, guiLeft - 70, this.guiTop + 2, 70, 22, "1"));
|
||||
addSideButton(new GuiMenuSideButton(22, guiLeft - 70, this.guiTop + 23, 70, 22, "2"));
|
||||
addSideButton(new GuiMenuSideButton(23, guiLeft - 70, this.guiTop + 44, 70, 22, "3"));
|
||||
addSideButton(new GuiMenuSideButton(24, guiLeft - 70, this.guiTop + 65, 70, 22, "4"));
|
||||
addSideButton(new GuiMenuSideButton(25, guiLeft - 70, this.guiTop + 86, 70, 22, "5"));
|
||||
addSideButton(new GuiMenuSideButton(26, guiLeft - 70, this.guiTop + 107, 35, 22, "6"));
|
||||
addSideButton(new GuiMenuSideButton(27, guiLeft - 35, this.guiTop + 107, 35, 22, "7"));
|
||||
addSideButton(new GuiMenuSideButton(28, guiLeft - 70, this.guiTop + 128, 35, 22, "8"));
|
||||
addSideButton(new GuiMenuSideButton(29, guiLeft - 35, this.guiTop + 128, 35, 22, "9"));
|
||||
addSideButton(new GuiMenuSideButton(30, guiLeft - 70, this.guiTop + 149, 35, 22, "10"));
|
||||
addSideButton(new GuiMenuSideButton(31, guiLeft - 35, this.guiTop + 149, 35, 22, "11"));
|
||||
addSideButton(new GuiMenuSideButton(32, guiLeft - 70, this.guiTop + 170, 35, 22, "12"));
|
||||
addSideButton(new GuiMenuSideButton(33, guiLeft - 35, this.guiTop + 170, 35, 22, "13"));
|
||||
addSideButton(new GuiMenuSideButton(34, guiLeft - 70, this.guiTop + 191, 35, 22, "14"));
|
||||
addSideButton(new GuiMenuSideButton(35, guiLeft - 35, this.guiTop + 191, 35, 22, "15"));
|
||||
|
||||
addButton(new GuiNpcButton(6, guiLeft + 298, guiTop + 190, 52, 20, "gui.remove"));
|
||||
|
||||
getSideButton(20 + activeTab).active = true;
|
||||
// Tabs/Folders toggle above side buttons
|
||||
addButton(new GuiNpcButton(60, guiLeft - 70, guiTop - 18, 70, 16,
|
||||
new String[]{"Tabs", "Folders"}, sidebarMode));
|
||||
|
||||
if (sidebarMode == 0) {
|
||||
initTabSideButtons();
|
||||
} else {
|
||||
initFolderSideButtons();
|
||||
}
|
||||
|
||||
showClones();
|
||||
} else {
|
||||
showEntities();
|
||||
}
|
||||
} else {
|
||||
// Show Filters
|
||||
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.tagFilters"), guiLeft + 7, guiTop + 7));
|
||||
addScroll(filterScroll);
|
||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, tagSearch));
|
||||
|
||||
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("cloner.tagVisibility"), guiLeft + 150, guiTop + 27));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 215, guiTop + 20, new String[]{"display.show", "display.all", "display.hide"}, displayTags));
|
||||
|
||||
addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("filter.contains"), guiLeft + 150, guiTop + 50));
|
||||
addButton(new GuiNpcButton(13, guiLeft + 215, guiTop + 43, new String[]{"filter.any", "filter.all", "filter.notany", "filter.notall"}, filterCondition));
|
||||
|
||||
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 66, 130, 20, "gui.deselectAll"));
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(4, StatCollector.translateToLocal("cloner.order"), guiLeft + 150, guiTop + 112));
|
||||
addButton(new GuiNpcButton(14, guiLeft + 215, guiTop + 105, new String[]{"cloner.ascending", "cloner.descending"}, ascending));
|
||||
|
||||
addLabel(new GuiNpcLabel(5, StatCollector.translateToLocal("cloner.type"), guiLeft + 150, guiTop + 135));
|
||||
addButton(new GuiNpcButton(15, guiLeft + 215, guiTop + 128, new String[]{"cloner.name", "cloner.date"}, sortType));
|
||||
|
||||
|
||||
getButton(12).width = 65;
|
||||
getButton(12).height = 20;
|
||||
|
||||
getButton(13).width = 65;
|
||||
getButton(13).height = 20;
|
||||
|
||||
getButton(14).width = 65;
|
||||
getButton(14).height = 20;
|
||||
|
||||
getButton(15).width = 65;
|
||||
getButton(15).height = 20;
|
||||
|
||||
showFilters();
|
||||
showFiltersPage();
|
||||
}
|
||||
}
|
||||
|
||||
public int getShowingClones() {
|
||||
return showingClones;
|
||||
private void initTabSideButtons() {
|
||||
// Tabs 1-5: full width (70px)
|
||||
addSideButton(new GuiMenuSideButton(21, guiLeft - 70, guiTop + 2, 70, 22, "1"));
|
||||
addSideButton(new GuiMenuSideButton(22, guiLeft - 70, guiTop + 23, 70, 22, "2"));
|
||||
addSideButton(new GuiMenuSideButton(23, guiLeft - 70, guiTop + 44, 70, 22, "3"));
|
||||
addSideButton(new GuiMenuSideButton(24, guiLeft - 70, guiTop + 65, 70, 22, "4"));
|
||||
addSideButton(new GuiMenuSideButton(25, guiLeft - 70, guiTop + 86, 70, 22, "5"));
|
||||
// Tabs 6-15: half width (35px), 2-column grid
|
||||
addSideButton(new GuiMenuSideButton(26, guiLeft - 70, guiTop + 107, 35, 22, "6"));
|
||||
addSideButton(new GuiMenuSideButton(27, guiLeft - 35, guiTop + 107, 35, 22, "7"));
|
||||
addSideButton(new GuiMenuSideButton(28, guiLeft - 70, guiTop + 128, 35, 22, "8"));
|
||||
addSideButton(new GuiMenuSideButton(29, guiLeft - 35, guiTop + 128, 35, 22, "9"));
|
||||
addSideButton(new GuiMenuSideButton(30, guiLeft - 70, guiTop + 149, 35, 22, "10"));
|
||||
addSideButton(new GuiMenuSideButton(31, guiLeft - 35, guiTop + 149, 35, 22, "11"));
|
||||
addSideButton(new GuiMenuSideButton(32, guiLeft - 70, guiTop + 170, 35, 22, "12"));
|
||||
addSideButton(new GuiMenuSideButton(33, guiLeft - 35, guiTop + 170, 35, 22, "13"));
|
||||
addSideButton(new GuiMenuSideButton(34, guiLeft - 70, guiTop + 191, 35, 22, "14"));
|
||||
addSideButton(new GuiMenuSideButton(35, guiLeft - 35, guiTop + 191, 35, 22, "15"));
|
||||
|
||||
if (activeFolder == null && activeTab >= 1 && activeTab <= 15) {
|
||||
GuiMenuSideButton active = getSideButton(20 + activeTab);
|
||||
if (active != null) active.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void showFilters() {
|
||||
private void initFolderSideButtons() {
|
||||
folderSideButtons.clear();
|
||||
for (int i = 0; i < folderNames.size(); i++) {
|
||||
String name = folderNames.get(i);
|
||||
GuiMenuSideButton btn = new GuiMenuSideButton(i, guiLeft - 70, guiTop + 2 + i * 21, 70, 22, name);
|
||||
if (name.equals(activeFolder)) {
|
||||
btn.active = true;
|
||||
}
|
||||
folderSideButtons.put(i, btn);
|
||||
}
|
||||
|
||||
// Folder CRUD buttons below visible scroll area (8 slots)
|
||||
int crudY = guiTop + 2 + 8 * 21;
|
||||
addButton(new GuiNpcButton(40, guiLeft - 70, crudY, 22, 20, "+"));
|
||||
if (activeFolder != null) {
|
||||
addButton(new GuiNpcButton(41, guiLeft - 47, crudY, 28, 20, "Ren"));
|
||||
GuiNpcButton delBtn = new GuiNpcButton(42, guiLeft - 18, crudY, 22, 20, "-");
|
||||
if (ClientCloneController.Instance != null) {
|
||||
List<String> clones = ClientCloneController.Instance.getClones(activeFolder);
|
||||
delBtn.enabled = clones == null || clones.isEmpty();
|
||||
}
|
||||
addButton(delBtn);
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== FILTERS PAGE ====================
|
||||
private void showFiltersPage() {
|
||||
int baseY = guiTop;
|
||||
|
||||
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.tagFilters"),
|
||||
guiLeft + 7, baseY + 7));
|
||||
|
||||
filterScroll.clear();
|
||||
filterScroll.setSize(140, 166);
|
||||
filterScroll.guiLeft = guiLeft + 4;
|
||||
filterScroll.guiTop = baseY + 19;
|
||||
filterScroll.multipleSelection = true;
|
||||
filterScroll.setSelectedList(tagFilters);
|
||||
addScroll(filterScroll);
|
||||
|
||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj,
|
||||
guiLeft + 4, baseY + 190, 140, 20, tagSearch));
|
||||
|
||||
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("cloner.tagVisibility"),
|
||||
guiLeft + 150, baseY + 27));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 215, baseY + 20,
|
||||
new String[]{"display.show", "display.all", "display.hide"}, displayTags));
|
||||
|
||||
addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("filter.contains"),
|
||||
guiLeft + 150, baseY + 50));
|
||||
addButton(new GuiNpcButton(13, guiLeft + 215, baseY + 43,
|
||||
new String[]{"filter.any", "filter.all", "filter.notany", "filter.notall"}, filterCondition));
|
||||
|
||||
addButton(new GuiNpcButton(11, guiLeft + 150, baseY + 66, 130, 20, "gui.deselectAll"));
|
||||
|
||||
addLabel(new GuiNpcLabel(4, StatCollector.translateToLocal("cloner.order"),
|
||||
guiLeft + 150, baseY + 112));
|
||||
addButton(new GuiNpcButton(14, guiLeft + 215, baseY + 105,
|
||||
new String[]{"cloner.ascending", "cloner.descending"}, ascending));
|
||||
|
||||
addLabel(new GuiNpcLabel(5, StatCollector.translateToLocal("cloner.type"),
|
||||
guiLeft + 150, baseY + 135));
|
||||
addButton(new GuiNpcButton(15, guiLeft + 215, baseY + 128,
|
||||
new String[]{"cloner.name", "cloner.date"}, sortType));
|
||||
|
||||
getButton(12).width = 65;
|
||||
getButton(12).height = 20;
|
||||
getButton(13).width = 65;
|
||||
getButton(13).height = 20;
|
||||
getButton(14).width = 65;
|
||||
getButton(14).height = 20;
|
||||
getButton(15).width = 65;
|
||||
getButton(15).height = 20;
|
||||
|
||||
filterScroll.setList(getTagList());
|
||||
}
|
||||
|
||||
private void showEntities() {
|
||||
Map<?, ?> data = EntityList.stringToClassMapping;
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (Object name : data.keySet()) {
|
||||
Class<?> c = (Class<?>) data.get(name);
|
||||
try {
|
||||
if (EntityLiving.class.isAssignableFrom(c) && c.getConstructor(new Class[]{World.class}) != null && !Modifier.isAbstract(c.getModifiers()))
|
||||
list.add(name.toString());
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
|
||||
// ==================== CLONE / ENTITY DISPLAY ====================
|
||||
private void showClones() {
|
||||
if (activeFolder != null) {
|
||||
showFolderClones();
|
||||
return;
|
||||
}
|
||||
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneTagListPacket(activeTab));
|
||||
PacketClient.sendClient(new CloneListPacket(activeTab));
|
||||
@@ -219,16 +304,64 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab);
|
||||
populateRawListWithTags();
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
|
||||
private void showFolderClones() {
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneTagListPacket(activeFolder));
|
||||
PacketClient.sendClient(new CloneListPacket(activeFolder));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ClientCloneController.Instance != null) {
|
||||
if (sortType == 0) {
|
||||
this.list = ClientCloneController.Instance.getClones(activeFolder);
|
||||
} else {
|
||||
this.list = ClientCloneController.Instance.getClonesDate(activeFolder);
|
||||
}
|
||||
this.tagMap = ClientTagMapController.Instance.getTagMap(activeFolder);
|
||||
} else {
|
||||
this.list = new ArrayList<>();
|
||||
this.tagMap = null;
|
||||
}
|
||||
|
||||
populateRawListWithTags();
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
|
||||
private void showEntities() {
|
||||
Map<?, ?> data = EntityList.stringToClassMapping;
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (Object name : data.keySet()) {
|
||||
Class<?> c = (Class<?>) data.get(name);
|
||||
try {
|
||||
if (EntityLiving.class.isAssignableFrom(c)
|
||||
&& c.getConstructor(new Class[]{World.class}) != null
|
||||
&& !Modifier.isAbstract(c.getModifiers()))
|
||||
list.add(name.toString());
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
|
||||
private void populateRawListWithTags() {
|
||||
this.rawList = new ArrayList<>(this.list);
|
||||
if (this.tagMap != null) {
|
||||
if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) {
|
||||
if (displayTags == 0 || displayTags == 1) {
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))) {
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if (tag != null) {
|
||||
if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) {
|
||||
if (displayTags == 1 || !tag.getIsHidden()) {
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
@@ -238,27 +371,29 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
if (getTextField(1) != null) {
|
||||
if (search.equals(getTextField(1).getText()))
|
||||
return;
|
||||
search = getTextField(1).getText().toLowerCase();
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
if (getTextField(2) != null) {
|
||||
if (tagSearch.equals(getTextField(2).getText()))
|
||||
return;
|
||||
tagSearch = getTextField(2).getText().toLowerCase();
|
||||
filterScroll.setList(getTagList());
|
||||
}
|
||||
private NBTTagCompound getCompound() {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null)
|
||||
return null;
|
||||
|
||||
if (showingClones == 0) {
|
||||
if (activeFolder != null && ClientCloneController.Instance != null) {
|
||||
return ClientCloneController.Instance.getCloneData(player, sel, activeFolder);
|
||||
}
|
||||
return ClientCloneController.Instance.getCloneData(player, sel, activeTab);
|
||||
} else {
|
||||
Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld);
|
||||
if (entity == null)
|
||||
return null;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
entity.writeToNBTOptional(compound);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== SEARCH / FILTER ====================
|
||||
private List<String> getSearchList() {
|
||||
if (this.list == null) {
|
||||
this.list = new ArrayList<String>();
|
||||
@@ -269,10 +404,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
|
||||
// No Filters - or - Entities
|
||||
if (tagFilters.size() == 0 || showingClones == 1) {
|
||||
// No Search
|
||||
if (search.isEmpty())
|
||||
return new ArrayList<String>(this.list);
|
||||
// Yes Search
|
||||
else {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
@@ -284,10 +417,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
//// WITH FILTERS
|
||||
|
||||
// No Search
|
||||
// With Filters
|
||||
if (search.isEmpty()) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : this.list) {
|
||||
@@ -300,7 +430,6 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
return list;
|
||||
}
|
||||
|
||||
// Yes Search
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
if (this.rawList.get(i).toLowerCase().contains(search)) {
|
||||
@@ -311,7 +440,6 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -346,7 +474,6 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return conditionMet;
|
||||
}
|
||||
|
||||
@@ -354,10 +481,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
if (this.tagList == null) {
|
||||
this.tagList = new ArrayList<String>();
|
||||
}
|
||||
// No Search // No Filters - or - Entities
|
||||
if (tagSearch.isEmpty())
|
||||
return new ArrayList<String>(tagNames.keySet());
|
||||
// Yes Search // No Filters - or - Entities
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : this.tagList) {
|
||||
@@ -367,60 +492,111 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
return list;
|
||||
}
|
||||
|
||||
private NBTTagCompound getCompound() {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null)
|
||||
return null;
|
||||
// ==================== RENDERING ====================
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
super.drawScreen(i, j, f);
|
||||
|
||||
if (showingClones == 0) {
|
||||
return ClientCloneController.Instance.getCloneData(player, sel, activeTab);
|
||||
} else {
|
||||
Entity entity = EntityList.createEntityByName(sel, Minecraft.getMinecraft().theWorld);
|
||||
if (entity == null)
|
||||
return null;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
entity.writeToNBTOptional(compound);
|
||||
return compound;
|
||||
// Render scrollable folder side buttons (folders mode only)
|
||||
if (sidebarMode == 1 && (showingClones == 0 || showingClones == 2)) {
|
||||
renderFolderSideButtons(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFolderSideButtons(int mouseX, int mouseY) {
|
||||
final float SMOOTHING_FACTOR = 0.1F;
|
||||
int maxScroll = Math.max(0, folderSideButtons.size() - 8) * 21;
|
||||
|
||||
if (isMouseInFolderScrollZone(mouseX, mouseY)) {
|
||||
int wheel = Mouse.getDWheel();
|
||||
if (wheel != 0) {
|
||||
destFolderScroll = ValueUtil.clamp(
|
||||
destFolderScroll - Math.signum(wheel) * 21, -maxScroll, 0);
|
||||
}
|
||||
}
|
||||
|
||||
folderScroll += (destFolderScroll - folderScroll) * SMOOTHING_FACTOR;
|
||||
|
||||
for (Map.Entry<Integer, GuiMenuSideButton> entry : folderSideButtons.entrySet()) {
|
||||
int idx = entry.getKey();
|
||||
GuiMenuSideButton button = entry.getValue();
|
||||
|
||||
float rawY = guiTop + 2 + idx * 21 + folderScroll;
|
||||
int smoothedY = Math.round(rawY);
|
||||
|
||||
if (smoothedY >= guiTop && smoothedY < guiTop + 8 * 21) {
|
||||
button.yPosition = smoothedY;
|
||||
button.drawButton(mc, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMouseInFolderScrollZone(int x, int y) {
|
||||
return x >= guiLeft - 70 && x <= guiLeft
|
||||
&& y >= guiTop + 2 && y <= guiTop + 2 + 8 * 21;
|
||||
}
|
||||
|
||||
// ==================== MOUSE / KEYBOARD EVENTS ====================
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
// Handle folder side button clicks (folders mode)
|
||||
if (sidebarMode == 1 && (showingClones == 0 || showingClones == 2) && k == 0) {
|
||||
for (GuiMenuSideButton button : new ArrayList<>(folderSideButtons.values())) {
|
||||
if (button.mousePressed(mc, i, j)) {
|
||||
folderSideButtonPressed(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void folderSideButtonPressed(GuiMenuSideButton button) {
|
||||
if (button.active) return;
|
||||
NoppesUtil.clickSound();
|
||||
activeFolder = button.displayString;
|
||||
activeTab = -1;
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollDoubleClicked(String selection, GuiCustomScroll guiCustomScroll) {
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
if (getTextField(1) != null) {
|
||||
if (search.equals(getTextField(1).getText()))
|
||||
return;
|
||||
search = getTextField(1).getText().toLowerCase();
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
if (getTextField(2) != null) {
|
||||
if (tagSearch.equals(getTextField(2).getText()))
|
||||
return;
|
||||
tagSearch = getTextField(2).getText().toLowerCase();
|
||||
filterScroll.setList(getTagList());
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== BUTTON ACTIONS ====================
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
if (id == 0) {
|
||||
close();
|
||||
}
|
||||
if (id == 1) {
|
||||
if (showingClones == 2) {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null)
|
||||
return;
|
||||
SpawnMobPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
} else {
|
||||
NBTTagCompound compound = getCompound();
|
||||
if (compound == null)
|
||||
return;
|
||||
SpawnMobPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
}
|
||||
}
|
||||
if (id == 2) {
|
||||
if (showingClones == 2) {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null)
|
||||
return;
|
||||
MobSpawnerPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
} else {
|
||||
NBTTagCompound compound = getCompound();
|
||||
if (compound == null)
|
||||
return;
|
||||
MobSpawnerPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
|
||||
}
|
||||
// Tab side buttons (IDs 21-35)
|
||||
if (id >= 21 && id <= 35) {
|
||||
activeTab = id - 20;
|
||||
activeFolder = null;
|
||||
initGui();
|
||||
return;
|
||||
}
|
||||
|
||||
// Mode buttons
|
||||
if (id == 3) {
|
||||
showingClones = 0;
|
||||
initGui();
|
||||
@@ -440,53 +616,222 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
if (id == 17) {
|
||||
close();
|
||||
}
|
||||
|
||||
// Open fullscreen GUI
|
||||
if (id == 61) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(
|
||||
new GuiNpcMobSpawnerFullscreen(posX, posY, posZ));
|
||||
}
|
||||
|
||||
// Tabs/Folders toggle
|
||||
if (id == 60) {
|
||||
sidebarMode = ((GuiNpcButton) guibutton).getValue();
|
||||
if (sidebarMode == 1 && activeFolder == null && !folderNames.isEmpty()) {
|
||||
activeFolder = folderNames.get(0);
|
||||
activeTab = -1;
|
||||
}
|
||||
if (sidebarMode == 0 && (activeTab < 1 || activeTab > 15)) {
|
||||
activeTab = 1;
|
||||
activeFolder = null;
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
// Spawn
|
||||
if (id == 1) {
|
||||
if (showingClones == 2) {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null) return;
|
||||
if (activeFolder != null)
|
||||
SpawnMobPacket.ServerFolder(posX, posY, posZ, sel, activeFolder);
|
||||
else
|
||||
SpawnMobPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
} else {
|
||||
NBTTagCompound compound = getCompound();
|
||||
if (compound == null) return;
|
||||
SpawnMobPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
// Mob Spawner
|
||||
if (id == 2) {
|
||||
if (showingClones == 2) {
|
||||
String sel = scroll.getSelected();
|
||||
if (sel == null) return;
|
||||
if (activeFolder != null)
|
||||
MobSpawnerPacket.ServerFolder(posX, posY, posZ, sel, activeFolder);
|
||||
else
|
||||
MobSpawnerPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
} else {
|
||||
NBTTagCompound compound = getCompound();
|
||||
if (compound == null) return;
|
||||
MobSpawnerPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove
|
||||
if (id == 6) {
|
||||
if (scroll.getSelected() != null) {
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneRemovePacket(activeTab, scroll.getSelected()));
|
||||
if (activeFolder != null)
|
||||
PacketClient.sendClient(new CloneRemovePacket(activeFolder, scroll.getSelected()));
|
||||
else
|
||||
PacketClient.sendClient(new CloneRemovePacket(activeTab, scroll.getSelected()));
|
||||
return;
|
||||
}
|
||||
ClientCloneController.Instance.removeClone(scroll.getSelected(), activeTab);
|
||||
if (activeFolder != null && ClientCloneController.Instance != null)
|
||||
ClientCloneController.Instance.removeClone(scroll.getSelected(), activeFolder);
|
||||
else
|
||||
ClientCloneController.Instance.removeClone(scroll.getSelected(), activeTab);
|
||||
scroll.selected = -1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
// Move
|
||||
if (id == 50) {
|
||||
if (scroll.getSelected() != null) {
|
||||
setSubGui(new SubGuiCloneMove());
|
||||
}
|
||||
}
|
||||
|
||||
// Filter controls
|
||||
if (id == 11) {
|
||||
tagFilters = new HashSet<>();
|
||||
filterScroll.setSelectedList(tagFilters);
|
||||
initGui();
|
||||
}
|
||||
if (id == 12) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
displayTags = (byte) button.getValue();
|
||||
displayTags = (byte) ((GuiNpcButton) guibutton).getValue();
|
||||
}
|
||||
if (id == 13) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
filterCondition = (byte) button.getValue();
|
||||
filterCondition = (byte) ((GuiNpcButton) guibutton).getValue();
|
||||
}
|
||||
if (id == 14) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
ascending = (byte) button.getValue();
|
||||
ascending = (byte) ((GuiNpcButton) guibutton).getValue();
|
||||
}
|
||||
if (id == 15) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
sortType = (byte) button.getValue();
|
||||
sortType = (byte) ((GuiNpcButton) guibutton).getValue();
|
||||
}
|
||||
if (id > 20) {
|
||||
activeTab = id - 20;
|
||||
initGui();
|
||||
|
||||
// Create folder
|
||||
if (id == 40) {
|
||||
setSubGui(new SubGuiCloneFolderName(""));
|
||||
}
|
||||
// Rename folder
|
||||
if (id == 41) {
|
||||
if (activeFolder != null)
|
||||
setSubGui(new SubGuiCloneFolderName(activeFolder));
|
||||
}
|
||||
// Delete folder
|
||||
if (id == 42) {
|
||||
if (activeFolder != null && ClientCloneController.Instance != null) {
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneFolderCrudPacket(
|
||||
CloneFolderCrudPacket.ACTION_DELETE, activeFolder));
|
||||
} else {
|
||||
ClientCloneController.Instance.deleteFolder(activeFolder);
|
||||
loadFolderNames();
|
||||
}
|
||||
activeFolder = null;
|
||||
activeTab = 1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== SUB GUI ====================
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if (subgui instanceof SubGuiCloneFolderName) {
|
||||
SubGuiCloneFolderName folderGui = (SubGuiCloneFolderName) subgui;
|
||||
if (folderGui.cancelled) return;
|
||||
|
||||
String newName = folderGui.getFolderName();
|
||||
if (newName == null || newName.isEmpty()) return;
|
||||
|
||||
if (folderGui.isRename()) {
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneFolderCrudPacket(
|
||||
CloneFolderCrudPacket.ACTION_RENAME, folderGui.getOriginalName(), newName));
|
||||
} else if (ClientCloneController.Instance != null) {
|
||||
ClientCloneController.Instance.renameFolder(folderGui.getOriginalName(), newName);
|
||||
loadFolderNames();
|
||||
}
|
||||
activeFolder = newName;
|
||||
activeTab = -1;
|
||||
} else {
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneFolderCrudPacket(
|
||||
CloneFolderCrudPacket.ACTION_CREATE, newName));
|
||||
} else if (ClientCloneController.Instance != null) {
|
||||
ClientCloneController.Instance.createFolder(newName);
|
||||
loadFolderNames();
|
||||
}
|
||||
activeFolder = newName;
|
||||
activeTab = -1;
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
if (subgui instanceof SubGuiCloneMove) {
|
||||
SubGuiCloneMove moveGui = (SubGuiCloneMove) subgui;
|
||||
if (!moveGui.cancelled) {
|
||||
String cloneName = scroll.getSelected();
|
||||
if (cloneName != null) {
|
||||
int fromTab = activeFolder != null ? -1 : activeTab;
|
||||
String fromFolder = activeFolder;
|
||||
int toTab = moveGui.getDestTab();
|
||||
String toFolder = moveGui.getDestFolder();
|
||||
|
||||
if (showingClones == 2) {
|
||||
PacketClient.sendClient(new CloneMovePacket(
|
||||
cloneName, fromTab, fromFolder, toTab, toFolder));
|
||||
} else if (ClientCloneController.Instance != null) {
|
||||
if (fromFolder != null && toFolder != null) {
|
||||
ClientCloneController.Instance.moveClone(cloneName, fromFolder, toFolder);
|
||||
} else if (fromFolder != null) {
|
||||
ClientCloneController.Instance.moveClone(cloneName, fromFolder, toTab);
|
||||
} else if (toFolder != null) {
|
||||
ClientCloneController.Instance.moveClone(cloneName, fromTab, toFolder);
|
||||
} else {
|
||||
ClientCloneController.Instance.moveClone(cloneName, fromTab, toTab);
|
||||
}
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== DATA FROM SERVER ====================
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if (compound.hasKey("CloneTags")) {
|
||||
this.tagMap = new TagMap(activeTab);
|
||||
if (compound.hasKey("CloneFolders")) {
|
||||
NBTTagList folderList = compound.getTagList("CloneFolders", 10);
|
||||
folderNames.clear();
|
||||
for (int i = 0; i < folderList.tagCount(); i++) {
|
||||
CloneFolder folder = new CloneFolder();
|
||||
folder.readNBT(folderList.getCompoundTagAt(i));
|
||||
folderNames.add(folder.name);
|
||||
}
|
||||
initGui();
|
||||
} else if (compound.hasKey("MoveSuccess")) {
|
||||
initGui();
|
||||
} else if (compound.hasKey("CloneTags")) {
|
||||
if (activeFolder != null) {
|
||||
this.tagMap = new TagMap(activeFolder);
|
||||
} else {
|
||||
this.tagMap = new TagMap(activeTab);
|
||||
}
|
||||
NBTTagCompound cloneTags = compound.getCompoundTag("CloneTags");
|
||||
this.tagMap.readNBT(cloneTags);
|
||||
} else if (compound.hasKey("AllTags")) {
|
||||
@@ -521,29 +866,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.list = list;
|
||||
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
if (this.tagMap != null) {
|
||||
if (GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1) {
|
||||
for (int i = 0; i < this.list.size(); i++) {
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))) {
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if (tag != null) {
|
||||
if (GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()) {
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rawList.set(i, npcName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
populateRawListWithTags();
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user