diff options
author | hackthetime <l4bg0jb7@duck.com> | 2023-12-14 12:57:03 +0100 |
---|---|---|
committer | HacktheTime <l4bg0jb7@duck.com> | 2023-12-15 18:17:42 +0100 |
commit | f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34 (patch) | |
tree | 328c9b25691e27aab8a4281e9c17e72fa5973868 /forge/src | |
parent | 709972ffd493632949282ca848fee848146a01ad (diff) | |
download | BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.tar.gz BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.tar.bz2 BBsentials-f8ab64f88f69ec50d5aca562f0ddbbf6ff7b0a34.zip |
a lot of prob not full working things
Diffstat (limited to 'forge/src')
3 files changed, 144 insertions, 21 deletions
diff --git a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java index 251b20b..8bb02f0 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/MCUtils.java @@ -3,14 +3,18 @@ package de.hype.bbsentials.forge; import com.mojang.authlib.exceptions.AuthenticationException; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.Display; import java.io.File; -import java.math.BigInteger; -import java.util.Random; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { public boolean isWindowFocused() { @@ -58,4 +62,109 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils { return serverId; } + public List<EntityPlayer> getAllPlayers() { + List<EntityPlayer> players = new ArrayList<>(); + + // Iterate through all players on the server + for (EntityPlayer player : Minecraft.getMinecraft().thePlayer.getEntityWorld().playerEntities) { + if (!player.getDisplayNameString().startsWith("!")) { + players.add(player); + } + } + + return players; + } + + public List<EntityPlayer> getPlayersInRadius(EntityPlayer referencePlayer, List<EntityPlayer> players, double radius) { + List<EntityPlayer> nearbyPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the reference player + for (EntityPlayer player : players) { + if (player != referencePlayer && player.getDistanceSq(referencePlayer.posX, referencePlayer.posY, referencePlayer.posZ) <= radius * radius) { + nearbyPlayers.add(player); + } + } + + return nearbyPlayers; + } + + + public List<String> getBingoPlayers() { + List<String> bingoPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (Iterator<NetworkPlayerInfo> it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { + NetworkPlayerInfo entry = it.next(); + try { + if (entry.getGameProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getUnformattedText(); + if (customName.contains("Ⓑ")) { + bingoPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return bingoPlayers; + } + + public List<String> getIronmanPlayers() { + List<String> ironmanPlayers = new ArrayList<>(); + + // Iterate through all players and check their distance from the source player + for (Iterator<NetworkPlayerInfo> it = Minecraft.getMinecraft().getNetHandler().getPlayerInfoMap().stream().iterator(); it.hasNext(); ) { + NetworkPlayerInfo entry = it.next(); + try { + if (entry.getGameProfile().getName().startsWith("!")) { + String customName = entry.getDisplayName().getUnformattedText(); + if (customName.contains("♻")) { + ironmanPlayers.add(customName.trim().split(" ")[1]); + } + } + } catch (Exception ignored) { + } + + } + return ironmanPlayers; + } + + public List<EntityPlayer> onlyFromList(List<EntityPlayer> players, List<String> usernames) { + ArrayList<EntityPlayer> filtered = new ArrayList<>(); + for (EntityPlayer player : players) { + String playerUsername = player.getGameProfile().getName(); + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + usernames.remove(i); + filtered.add(player); + } + } + } + return filtered; + } + + public List<EntityPlayer> filterOut(List<EntityPlayer> players, List<String> usernames) { + ArrayList<EntityPlayer> filtered = new ArrayList<>(); + for (EntityPlayer player : players) { + String playerUsername = player.getGameProfile().getName(); + boolean toAdd = true; + for (int i = 0; i < usernames.size(); i++) { + if (playerUsername.equals(usernames.get(i))) { + toAdd = false; + usernames.remove(i); + break; + } + } + if (toAdd) { + filtered.add(player); + } + } + return filtered; + } + + public List<String> getSplashLeechingPlayers() { + List<EntityPlayer> players = getAllPlayers(); + players.remove(Minecraft.getMinecraft().thePlayer); + return getPlayersInRadius(Minecraft.getMinecraft().thePlayer, filterOut(getAllPlayers(), getBingoPlayers()), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getFormattedText())).collect(Collectors.toList()); + } } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java index 4d50a4e..e0598ff 100644 --- a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java +++ b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfig.java @@ -4,43 +4,35 @@ import com.google.gson.annotations.Expose; import de.hype.bbsentials.forge.client.categories.FirstCategory; import io.github.moulberry.moulconfig.Config; import io.github.moulberry.moulconfig.annotations.Category; -import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; -import io.github.moulberry.moulconfig.annotations.ConfigOption; -import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper; -import io.github.moulberry.moulconfig.gui.MoulConfigEditor; -import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis; -import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver; -import io.github.moulberry.moulconfig.processor.MoulConfigProcessor; import net.minecraft.client.Minecraft; -import net.minecraftforge.common.config.ConfigCategory; +import net.minecraft.util.ChatComponentText; import static de.hype.bbsentials.common.client.BBsentials.config; public class MoulConfig extends Config { - MoulConfigEditor<MoulConfig> editor; - MoulConfigProcessor<MoulConfig> processor; @Expose @Category(name = "First Category", desc = "This is the first category.") public FirstCategory firstCategory = new FirstCategory(); - public MoulConfig() { - processor = new MoulConfigProcessor<>(this); - editor = new MoulConfigEditor<>(processor); - BuiltinMoulConfigGuis.addProcessors(processor); - ConfigProcessorDriver.processConfig(MoulConfig.class, this, processor); - } - @Override public String getTitle() { return "BBsentials " + de.hype.bbsentials.common.client.Config.apiVersion; } + @Override public void saveNow() { config.save(); } - public void openConfigGui() { - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenElementWrapper(editor)); + @Override + public void executeRunnable(int runnableId) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Just executed runnableId " + runnableId)); + } + + @Override + public boolean shouldAutoFocusSearchbar() { + return true; } + } diff --git a/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java new file mode 100644 index 0000000..07491cd --- /dev/null +++ b/forge/src/main/java/de/hype/bbsentials/forge/client/MoulConfigManager.java @@ -0,0 +1,22 @@ +package de.hype.bbsentials.forge.client; + +import io.github.moulberry.moulconfig.gui.MoulGuiOverlayEditor; +import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis; +import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver; +import io.github.moulberry.moulconfig.processor.MoulConfigProcessor; +import net.minecraft.client.Minecraft; + +public class MoulConfigManager { + static MoulConfig moulConfig = new MoulConfig(); + MoulConfigProcessor<MoulConfig> testConfigMoulConfigProcessor; + + public MoulConfigManager() { + testConfigMoulConfigProcessor = new MoulConfigProcessor<>(moulConfig); + BuiltinMoulConfigGuis.addProcessors(testConfigMoulConfigProcessor); + ConfigProcessorDriver.processConfig(moulConfig.getClass(), moulConfig, testConfigMoulConfigProcessor); + } + + public void openConfigGui() { + Minecraft.getMinecraft().displayGuiScreen(new MoulGuiOverlayEditor(testConfigMoulConfigProcessor)); + } +} |