Skip to content

Commit

Permalink
[Port] Update to 1.1.0 (v2.5.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Jan 14, 2025
1 parent 8e4dd16 commit b951d83
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.gitlab.cdagaming.craftpresence.core.impl.ExtendedModule;
import com.gitlab.cdagaming.unilib.utils.WorldUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.src.GuiPlayerInfo;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityList;

Expand Down Expand Up @@ -276,9 +275,9 @@ public void getInternalData() {

// If Server Data is enabled, allow Uuid's to count as entities
if (CraftPresence.SERVER.isEnabled()) {
for (GuiPlayerInfo playerInfo : CraftPresence.SERVER.currentPlayerList) {
for (String playerInfo : CraftPresence.SERVER.currentPlayerList) {
if (playerInfo != null) {
final String uuidString = playerInfo.name;
final String uuidString = playerInfo;
if (!StringUtils.isNullOrEmpty(uuidString)) {
if (!ENTITY_NAMES.contains(uuidString)) {
ENTITY_NAMES.add(uuidString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ServerList(Minecraft minecraft) {

public void loadServerList() {
try {
NBTTagCompound var1 = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));
NBTTagCompound var1 = CompressedStreamTools.writeMapToFileUncompressed(new File(this.mc.mcDataDir, "servers.dat"));
NBTTagList var2 = var1.getTagList("servers");
this.servers.clear();

Expand All @@ -63,12 +63,12 @@ public void saveServerList() {
NBTTagList var1 = new NBTTagList();

for(ServerNBTStorage var3 : this.servers) {
var1.appendTag(var3.getCompoundTag());
var1.setTag(var3.getCompoundTag());
}

NBTTagCompound var5 = new NBTTagCompound();
var5.setTag("servers", var1);
CompressedStreamTools.safeWrite(var5, new File(this.mc.mcDataDir, "servers.dat"));
CompressedStreamTools.saveMapToFileWithBackup(var5, new File(this.mc.mcDataDir, "servers.dat"));
} catch (Exception var4) {
var4.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class ServerUtils implements ExtendedModule {
/**
* The Current Player Map, if available
*/
public List<GuiPlayerInfo> currentPlayerList = StringUtils.newArrayList();
public List<String> currentPlayerList = StringUtils.newArrayList();
/**
* A List of the detected Server Addresses
*/
Expand Down Expand Up @@ -319,7 +319,7 @@ private ServerNBTStorage getOrCreateServerData(final String serverIP, final int
private void processData(final boolean newLANStatus, final boolean newSinglePlayerStatus,
final ServerNBTStorage newServerData, final NetClientHandler newConnection,
final String newServer_IP, final String newServer_MOTD, final String newServer_Name,
final int newCurrentPlayers, final int newMaxPlayers, final List<GuiPlayerInfo> newPlayerList) {
final int newCurrentPlayers, final int newMaxPlayers, final List<String> newPlayerList) {
final boolean isNewServer = newServerData != null && !newServerData.equals(currentServerData);
final boolean hasLeftServer = newServerData == null && currentServerData != null;
if (newLANStatus != isOnLAN || newSinglePlayerStatus != isOnSinglePlayer ||
Expand Down Expand Up @@ -430,7 +430,7 @@ private void processRealmData(final ServerNBTStorage newServerData, final NetCli
* @param newConnection The Player's Current Connection Data
*/
private void processServerData(final ServerNBTStorage newServerData, final NetClientHandler newConnection) {
final List<GuiPlayerInfo> newPlayerList = newConnection != null ? StringUtils.newArrayList(newConnection.playerNames) : StringUtils.newArrayList();
final List<String> newPlayerList = newConnection != null ? StringUtils.newArrayList(newConnection.playerNames) : StringUtils.newArrayList();
final int newCurrentPlayers = newConnection != null ? newConnection.playerNames.size() : 1;

final boolean newLANStatus = false;
Expand Down Expand Up @@ -693,7 +693,7 @@ public void initPresence() {
syncArgument("player.position.z", () -> MathUtils.roundDouble(CraftPresence.player.posZ, 3));

// Player Health Arguments
syncArgument("player.health.current", () -> MathUtils.roundDouble(CraftPresence.player.getHealth(), 0));
syncArgument("player.health.current", () -> MathUtils.roundDouble(CraftPresence.player.getEntityHealth(), 0));
syncArgument("player.health.max", () -> MathUtils.roundDouble(CraftPresence.player.getMaxHealth(), 0));

// World Data Arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void clearAttributes() {

@Override
public void updateData() {
final BiomeGenBase newBiome = CraftPresence.world.getBiomeGenForCoords((int) CraftPresence.player.posX, (int) CraftPresence.player.posZ);
final BiomeGenBase newBiome = CraftPresence.world.getWorldChunkManager().getBiomeGenAt((int) CraftPresence.player.posX, (int) CraftPresence.player.posZ);
final String newBiomeName = newBiome.biomeName;

final String newBiomeIdentifier = StringUtils.getOrDefault(newBiomeName, MappingUtils.getClassName(newBiome));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -188,37 +187,21 @@ private List<WorldProvider> getDimensionTypes() {
List<WorldProvider> dimensionTypes = StringUtils.newArrayList();

if (dimensionTypes.isEmpty()) {
// Fallback 1: Use Reflected Dimension Types
Map<?, ?> reflectedDimensionTypes = (Map<?, ?>) StringUtils.getField(FileUtils.loadClass("forge.DimensionManager"), null, "providers");
if (reflectedDimensionTypes != null) {
for (Object objectType : reflectedDimensionTypes.values()) {
// Use Manual Class Lookup
for (ClassInfo classInfo : FileUtils.getClassNamesMatchingSuperType(WorldProvider.class).values()) {
if (classInfo != null) {
try {
WorldProvider type = (objectType instanceof WorldProvider) ? (WorldProvider) objectType : null;

if (type != null && !dimensionTypes.contains(type)) {
dimensionTypes.add(type);
Class<?> classObj = FileUtils.loadClass(classInfo.getName());
if (classObj != null) {
WorldProvider providerObj = (WorldProvider) classObj.getDeclaredConstructor().newInstance();
if (!dimensionTypes.contains(providerObj)) {
dimensionTypes.add(providerObj);
}
}
} catch (Throwable ex) {
printException(ex);
}
}
} else if (FileUtils.isClassGraphEnabled()) {
// Fallback 2: Use Manual Class Lookup
for (ClassInfo classInfo : FileUtils.getClassNamesMatchingSuperType(WorldProvider.class).values()) {
if (classInfo != null) {
try {
Class<?> classObj = FileUtils.loadClass(classInfo.getName());
if (classObj != null) {
WorldProvider providerObj = (WorldProvider) classObj.getDeclaredConstructor().newInstance();
if (!dimensionTypes.contains(providerObj)) {
dimensionTypes.add(providerObj);
}
}
} catch (Throwable ex) {
printException(ex);
}
}
}
}
}

Expand Down Expand Up @@ -270,7 +253,7 @@ public String getOverrideText(ModuleData data) {

@Override
public boolean canFetchInternals() {
return MappingUtils.areMappingsLoaded() && (!FileUtils.isClassGraphEnabled() || FileUtils.canScanClasses());
return MappingUtils.areMappingsLoaded() && FileUtils.isClassGraphEnabled() && FileUtils.canScanClasses();
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ enabled_platforms=fabric,modloader
isLegacy=true
isJarMod=true
# Mapping Info
mc_mappings=6.2-1.2.5
mc_mappings=5.6-1.1
mc_mappings_type=mcp
mc_version=1.2.5
mc_protocol=29
mc_version=1.1
mc_protocol=23
display_version=
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=
fabric_game_version_range=1.2.5
fabric_game_version_range=1.1
fabric_loader_version_range=>=0.12.0
# Forge Info
forge_version=1.2.5
forge_version=1.1
fml_version_range=
forge_game_version_range=1.2.5
forge_game_version_range=1.1
forge_loader_version_range=
# Deployment Info
versionId=2.5.3
Expand Down

0 comments on commit b951d83

Please sign in to comment.