Skip to content

Commit

Permalink
[Port] Update to special/bta-7.3 (v2.5.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Dec 12, 2024
1 parent 1f1cd3f commit c389a04
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import io.github.cdagaming.unicore.utils.OSUtils;
import io.github.cdagaming.unicore.utils.ScheduleUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.entity.player.Player;
import net.minecraft.core.player.Session;
import net.minecraft.core.world.World;

Expand Down Expand Up @@ -107,7 +107,7 @@ public class CraftPresence {
/**
* The Current Player detected from the Minecraft Instance
*/
public static EntityPlayer player;
public static Player player;
/**
* The Current World detected from the Minecraft Instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
import com.gitlab.cdagaming.unilib.utils.gui.controls.ExtendedButtonControl;
import com.gitlab.cdagaming.unilib.utils.gui.widgets.ScrollableTextWidget;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.Screen;

public class MainGui extends ConfigurationGui<Config> {
private final Config INSTANCE, DEFAULTS;
private ExtendedButtonControl biomeSet,
dimensionSet,
serverSet;

public MainGui(GuiScreen parentScreen) {
public MainGui(Screen parentScreen) {
super(
Constants.TRANSLATOR.translate("gui.config.title")
);
Expand Down Expand Up @@ -232,11 +232,11 @@ calc2, getButtonY(currentY),
}

@Override
public void keyTyped(char typedChar, int keyCode, int mouseX, int mouseY) {
public void keyPressed(char typedChar, int keyCode, int mouseX, int mouseY) {
if (isEscapeKey(keyCode) && getCurrentData().hasChanged()) {
syncData();
}
super.keyTyped(typedChar, keyCode, mouseX, mouseY);
super.keyPressed(typedChar, keyCode, mouseX, mouseY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import io.github.cdagaming.unicore.utils.FileUtils;
import io.github.cdagaming.unicore.utils.MappingUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.Screen;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
Expand Down Expand Up @@ -99,8 +99,8 @@ public void updateData() {
final Class<?> screenClass = FileUtils.loadClass("com.replaymod.lib.de.johni0702.minecraft.gui.container.GuiScreen");
final Class<?> overlayClass = FileUtils.loadClass("com.replaymod.lib.de.johni0702.minecraft.gui.container.GuiOverlay");

final Object possibleScreen = StringUtils.executeMethod(screenClass, null, new Class[]{GuiScreen.class}, new Object[]{CraftPresence.GUIS.CURRENT_SCREEN}, "from");
final Object possibleOverlay = StringUtils.executeMethod(overlayClass, null, new Class[]{GuiScreen.class}, new Object[]{CraftPresence.GUIS.CURRENT_SCREEN}, "from");
final Object possibleScreen = StringUtils.executeMethod(screenClass, null, new Class[]{Screen.class}, new Object[]{CraftPresence.GUIS.CURRENT_SCREEN}, "from");
final Object possibleOverlay = StringUtils.executeMethod(overlayClass, null, new Class[]{Screen.class}, new Object[]{CraftPresence.GUIS.CURRENT_SCREEN}, "from");
if (possibleScreen == null && possibleOverlay == null) {
clearClientData();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.EntityDispatcher;
import net.minecraft.core.util.collection.NamespaceID;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -257,10 +258,10 @@ public void updatePresence() {

@Override
public void getInternalData() {
final Map mappings = (Map) StringUtils.getField(EntityDispatcher.class, null, "classToKeyMap", "field_1610_b", "b");
final Map<Class<? extends Entity>, NamespaceID> mappings = EntityDispatcher.classToIdMap;
if (!mappings.values().isEmpty()) {
for (Object entityLocationObj : mappings.values()) {
final String entityLocation = (String) entityLocationObj;
for (NamespaceID entityLocationObj : mappings.values()) {
final String entityLocation = entityLocationObj.value;
if (entityLocation != null) {
final String entityName = StringUtils.getOrDefault(entityLocation, "generic");
if (!DEFAULT_NAMES.contains(entityName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.gitlab.cdagaming.unilib.utils.ItemUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.core.block.Block;
import net.minecraft.core.block.Blocks;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;

Expand Down Expand Up @@ -365,7 +366,7 @@ public void updatePresence() {

@Override
public void getInternalData() {
for (Block block : Block.blocksList) {
for (Block block : Blocks.blocksList) {
if (!ItemUtils.isItemEmpty(block)) {
final ItemStack stack = ItemUtils.getStackFrom(block);
final String blockName = ItemUtils.getItemName(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import io.github.cdagaming.unicore.utils.FileUtils;
import io.github.cdagaming.unicore.utils.MappingUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.client.gui.GuiContainer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.Screen;
import net.minecraft.client.gui.container.ScreenContainerAbstract;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class GuiUtils implements ExtendedModule {
/**
* The Current Instance of the Gui the player is in
*/
public GuiScreen CURRENT_SCREEN;
public Screen CURRENT_SCREEN;
/**
* Whether this module is allowed to start and enabled
*/
Expand Down Expand Up @@ -107,14 +107,14 @@ public void clearAttributes() {

@Override
public void updateData() {
final GuiScreen newScreen = GameUtils.getCurrentScreen(CraftPresence.instance);
final Screen newScreen = GameUtils.getCurrentScreen(CraftPresence.instance);

if (newScreen == null) {
clearClientData();
} else {
final String newScreenName = StringUtils.getOrDefault(
MappingUtils.getClassName(newScreen),
MappingUtils.getClassName(GuiScreen.class)
MappingUtils.getClassName(Screen.class)
);

if (!newScreen.equals(CURRENT_SCREEN) || !newScreenName.equals(CURRENT_GUI_NAME)) {
Expand All @@ -139,7 +139,7 @@ public void updateData() {

@Override
public void getInternalData() {
final List<Class<?>> searchClasses = StringUtils.newArrayList(GuiScreen.class, GuiContainer.class);
final List<Class<?>> searchClasses = StringUtils.newArrayList(Screen.class, ScreenContainerAbstract.class);

for (ClassInfo classObj : FileUtils.getClassNamesMatchingSuperType(searchClasses).values()) {
final String screenName = MappingUtils.getClassName(classObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private void checkCommands() {
}

@Override
public void keyTyped(char typedChar, int keyCode, int mouseX, int mouseY) {
public void keyPressed(char typedChar, int keyCode, int mouseX, int mouseY) {
if (!blockInteractions) {
if (commandInput.isControlFocused()) {
if (isEscapeKey(keyCode)) {
Expand All @@ -503,7 +503,7 @@ public void keyTyped(char typedChar, int keyCode, int mouseX, int mouseY) {
}
}
}
super.keyTyped(typedChar, keyCode, mouseX, mouseY);
super.keyPressed(typedChar, keyCode, mouseX, mouseY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.gitlab.cdagaming.craftpresence.utils.gui.controls.DynamicScrollableList;
import com.gitlab.cdagaming.unilib.utils.gui.impl.SelectorGui;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.Screen;

import java.util.List;
import java.util.Set;
Expand All @@ -51,7 +51,7 @@ public class DynamicSelectorGui extends SelectorGui {
* @param onUpdatedCallback The callback to trigger when continuing following selection
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, String> onUpdatedCallback, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, String> onUpdatedCallback, BiConsumer<String, Screen> onAdjustDynamicEntry) {
super(mainTitle, list, currentValue, attributeName, allowContinuing, allowDynamicEditing, onUpdatedCallback, onAdjustDynamicEntry);
this.renderType = renderType;
}
Expand All @@ -69,7 +69,7 @@ public DynamicSelectorGui(String mainTitle, List<String> list, String currentVal
* @param onUpdatedCallback The callback to trigger when continuing following selection
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, String> onUpdatedCallback, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, String> onUpdatedCallback, BiConsumer<String, Screen> onAdjustDynamicEntry) {
this(mainTitle, StringUtils.newArrayList(list), currentValue, attributeName, allowContinuing, allowDynamicEditing, renderType, onUpdatedCallback, onAdjustDynamicEntry);
}

Expand All @@ -85,7 +85,7 @@ public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValu
* @param renderType The {@link DynamicScrollableList.RenderType} for the list, adjusting its look and feel
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, Screen> onAdjustDynamicEntry) {
this(mainTitle, list, currentValue, attributeName, allowContinuing, allowDynamicEditing, renderType, null, onAdjustDynamicEntry);
}

Expand All @@ -101,7 +101,7 @@ public DynamicSelectorGui(String mainTitle, List<String> list, String currentVal
* @param renderType The {@link DynamicScrollableList.RenderType} for the list, adjusting its look and feel
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, DynamicScrollableList.RenderType renderType, BiConsumer<String, Screen> onAdjustDynamicEntry) {
this(mainTitle, list, currentValue, attributeName, allowContinuing, allowDynamicEditing, renderType, null, onAdjustDynamicEntry);
}

Expand All @@ -116,7 +116,7 @@ public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValu
* @param allowDynamicEditing Whether to allow adding new entries to the list
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, List<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, BiConsumer<String, Screen> onAdjustDynamicEntry) {
this(mainTitle, list, currentValue, attributeName, allowContinuing, allowDynamicEditing, DynamicScrollableList.RenderType.None, onAdjustDynamicEntry);
}

Expand All @@ -131,7 +131,7 @@ public DynamicSelectorGui(String mainTitle, List<String> list, String currentVal
* @param allowDynamicEditing Whether to allow adding new entries to the list
* @param onAdjustDynamicEntry The callback to trigger when adjusting a dynamic entry
*/
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, BiConsumer<String, GuiScreen> onAdjustDynamicEntry) {
public DynamicSelectorGui(String mainTitle, Set<String> list, String currentValue, String attributeName, boolean allowContinuing, boolean allowDynamicEditing, BiConsumer<String, Screen> onAdjustDynamicEntry) {
this(mainTitle, list, currentValue, attributeName, allowContinuing, allowDynamicEditing, DynamicScrollableList.RenderType.None, onAdjustDynamicEntry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import io.github.cdagaming.unicore.utils.MathUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import io.github.cdagaming.unicore.utils.TimeUtils;
import net.minecraft.client.gui.GuiConnecting;
import net.minecraft.client.net.handler.NetClientHandler;
import net.minecraft.client.gui.ScreenConnecting;
import net.minecraft.client.net.handler.PacketHandlerClient;
import net.minecraft.core.net.NetworkManager;

import java.net.Socket;
Expand Down Expand Up @@ -151,7 +151,7 @@ public class ServerUtils implements ExtendedModule {
/**
* The Player's Current Connection Data
*/
private NetClientHandler currentConnection;
private PacketHandlerClient currentConnection;
/**
* If the RPC needs to be Updated or Re-Synchronized<p>
* Needed here for Multiple-Condition RPC Triggers
Expand Down Expand Up @@ -219,11 +219,11 @@ public void preTick() {
@Override
public void updateData() {
ServerNBTStorage newServerData;
final NetClientHandler newConnection = CraftPresence.instance.getSendQueue();
final PacketHandlerClient newConnection = CraftPresence.instance.getSendQueue();

try {
final NetworkManager netManager = (NetworkManager) StringUtils.getField(NetClientHandler.class, newConnection, "netManager", "field_1213_d", "e");
final Socket socket = (Socket) StringUtils.getField(NetworkManager.class, netManager, "networkSocket", "field_12258_e", "h");
final NetworkManager netManager = (NetworkManager) StringUtils.getField(PacketHandlerClient.class, newConnection, "netManager", "field_1213_d", "e");
final Socket socket = (Socket) StringUtils.getField(NetworkManager.class, netManager, "socket", "field_12258_e", "h");
final String retrievedIP = socket.getInetAddress().getHostAddress();
final int retrievedPort = socket.getPort();
newServerData = (!StringUtils.isNullOrEmpty(retrievedIP) && retrievedPort != 0) ? new ServerNBTStorage(retrievedIP, retrievedPort) : null;
Expand Down Expand Up @@ -273,7 +273,7 @@ public void updateData() {
* @param newPlayerList The Current Player Map, if available
*/
private void processData(final boolean newLANStatus, final boolean newSinglePlayerStatus,
final ServerNBTStorage newServerData, final NetClientHandler newConnection,
final ServerNBTStorage newServerData, final PacketHandlerClient newConnection,
final String newServer_IP, final String newServer_MOTD, final String newServer_Name,
final int newCurrentPlayers, final int newMaxPlayers, final List<String> newPlayerList) {
final boolean isNewServer = newServerData != null && !newServerData.equals(currentServerData);
Expand Down Expand Up @@ -367,7 +367,7 @@ private String getServerMotd(final ServerNBTStorage newServerData) {
* @param newServerData The Current Server Connection Data and Info
* @param newConnection The Player's Current Connection Data
*/
private void processRealmData(final ServerNBTStorage newServerData, final NetClientHandler newConnection) {
private void processRealmData(final ServerNBTStorage newServerData, final PacketHandlerClient newConnection) {
processServerData(newServerData, newConnection);
}

Expand All @@ -377,7 +377,7 @@ private void processRealmData(final ServerNBTStorage newServerData, final NetCli
* @param newServerData The Current Server Connection Data and Info
* @param newConnection The Player's Current Connection Data
*/
private void processServerData(final ServerNBTStorage newServerData, final NetClientHandler newConnection) {
private void processServerData(final ServerNBTStorage newServerData, final PacketHandlerClient newConnection) {
final List<String> newPlayerList = StringUtils.newArrayList();
final int newCurrentPlayers = 1;

Expand Down Expand Up @@ -574,7 +574,7 @@ private void joinServer(final ServerNBTStorage serverData) {

RenderUtils.openScreen(
CraftPresence.instance,
new GuiConnecting(
new ScreenConnecting(
CraftPresence.instance,
serverData.serverIP,
serverData.serverPort
Expand All @@ -600,7 +600,7 @@ public void initPresence() {
syncArgument("world.difficulty", () -> {
final String newDifficulty = false ?
ModUtils.RAW_TRANSLATOR.translate("selectWorld.gameMode.hardcore") :
Integer.toString(CraftPresence.world.difficultySetting);
Integer.toString(CraftPresence.world.getDifficulty().id());
return StringUtils.getOrDefault(newDifficulty);
});
syncArgument("world.weather.name", () -> {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ mc_mappings=4.3-b1.7.3
mc_mappings_type=mcp
mc_version=b1.7.3
mc_protocol=14
display_version=b7.2_01
display_version=b7.3_pre1
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=
fabric_game_version_range=*
fabric_loader_version_range=>=0.13.0
# Forge Info
forge_version=7.2_01
forge_version=7.3_pre1
fml_version_range=
forge_game_version_range=b1.7.3
forge_loader_version_range=
Expand Down
Binary file renamed libs/nsss-7.2_01.jar → libs/nsss-7.3_pre1.jar
Binary file not shown.

0 comments on commit c389a04

Please sign in to comment.