Skip to content

Commit

Permalink
[Port] Update to a1.1.2_01 (v2.5.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Jan 14, 2025
1 parent e2e2a59 commit 8104b0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void updateData() {
ServerNBTStorage newServerData;
try {
if (CraftPresence.world instanceof WorldClient clientWorld) {
newConnection = (NetClientHandler) StringUtils.getField(WorldClient.class, clientWorld, "sendQueue", "field_1052_A", "B");
newConnection = (NetClientHandler) StringUtils.getField(WorldClient.class, clientWorld, "sendQueue", "field_1052_A", "A");
}
} catch (Exception ex) {
newConnection = null;
Expand Down Expand Up @@ -578,7 +578,7 @@ private void joinServer(final ServerNBTStorage serverData) {

if (CraftPresence.player != null) {
CraftPresence.world.sendQuittingDisconnectingPacket();
CraftPresence.instance.func_6261_a(null);
CraftPresence.instance.changeWorld1(null);
}

RenderUtils.openScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
import com.gitlab.cdagaming.craftpresence.core.config.Config;
import com.gitlab.cdagaming.craftpresence.core.config.element.ModuleData;
import com.gitlab.cdagaming.craftpresence.core.impl.ExtendedModule;
import io.github.cdagaming.unicore.utils.FileUtils;
import io.github.cdagaming.unicore.utils.MappingUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.src.MobSpawnerBase;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
import java.util.function.Supplier;
Expand Down Expand Up @@ -67,7 +63,7 @@ public class BiomeUtils implements ExtendedModule {
/**
* Whether this module has performed an initial retrieval of internal items
*/
private boolean hasScannedInternals = false;
private boolean hasScannedInternals = true;
/**
* Whether this module has performed an initial event sync
*/
Expand All @@ -88,10 +84,6 @@ public class BiomeUtils implements ExtendedModule {
* The alternative display name for the Current Biome the Player is in, if any
*/
private String CURRENT_BIOME_IDENTIFIER;
/**
* The Player's Current Biome, if any
*/
private MobSpawnerBase CURRENT_BIOME;

@Override
public void clearFieldData() {
Expand All @@ -101,7 +93,6 @@ public void clearFieldData() {

@Override
public void clearAttributes() {
CURRENT_BIOME = null;
RAW_BIOME_NAME = null;
RAW_BIOME_IDENTIFIER = null;
CURRENT_BIOME_NAME = null;
Expand All @@ -114,16 +105,11 @@ public void clearAttributes() {

@Override
public void updateData() {
final MobSpawnerBase newBiome = CraftPresence.world.func_4075_a().func_4073_a((int) CraftPresence.player.posX, (int) CraftPresence.player.posZ);
final String newBiomeName = newBiome.biomeName;

final String newBiomeIdentifier = StringUtils.getOrDefault(newBiomeName, MappingUtils.getClassName(newBiome));

if (!newBiomeName.equals(RAW_BIOME_NAME) || !newBiomeIdentifier.equals(RAW_BIOME_IDENTIFIER)) {
CURRENT_BIOME = newBiome;
final String newBiomeName = "Plains"; // Stub

RAW_BIOME_NAME = StringUtils.getOrDefault(newBiomeName, newBiomeIdentifier);
RAW_BIOME_IDENTIFIER = newBiomeIdentifier;
if (!newBiomeName.equals(RAW_BIOME_NAME) || !newBiomeName.equals(RAW_BIOME_IDENTIFIER)) {
RAW_BIOME_NAME = newBiomeName;
RAW_BIOME_IDENTIFIER = newBiomeName;
CURRENT_BIOME_NAME = StringUtils.formatIdentifier(RAW_BIOME_NAME, false, !CraftPresence.CONFIG.advancedSettings.formatWords);
CURRENT_BIOME_IDENTIFIER = StringUtils.formatIdentifier(RAW_BIOME_IDENTIFIER, true, !CraftPresence.CONFIG.advancedSettings.formatWords);

Expand All @@ -146,8 +132,6 @@ public void updateData() {
public void initPresence() {
syncArgument("biome.default.icon", () -> CraftPresence.CONFIG.biomeSettings.fallbackBiomeIcon);

syncArgument("data.biome.instance", () -> CURRENT_BIOME);
syncArgument("data.biome.class", () -> CURRENT_BIOME.getClass());
syncArgument("data.biome.name", () -> RAW_BIOME_NAME, true);
syncArgument("data.biome.identifier", () -> RAW_BIOME_IDENTIFIER, true);

Expand Down Expand Up @@ -178,50 +162,9 @@ public void updatePresence() {
// N/A
}

/**
* Retrieves a List of detected Biome Types
*
* @return The detected Biome Types found
*/
private List<MobSpawnerBase> getBiomeTypes() {
List<MobSpawnerBase> biomeTypes = StringUtils.newArrayList();

if (biomeTypes.isEmpty()) {
// Fallback: Use Manual Class Lookup
for (ClassInfo classInfo : FileUtils.getClassNamesMatchingSuperType(MobSpawnerBase.class).values()) {
if (classInfo != null) {
try {
Class<?> classObj = FileUtils.loadClass(classInfo.getName());
if (classObj != null) {
MobSpawnerBase biomeObj = (MobSpawnerBase) classObj.getDeclaredConstructor().newInstance();
if (!biomeTypes.contains(biomeObj)) {
biomeTypes.add(biomeObj);
}
}
} catch (Throwable ex) {
printException(ex);
}
}
}
}

return biomeTypes;
}

@Override
public void getInternalData() {
for (MobSpawnerBase biome : getBiomeTypes()) {
if (biome != null) {
String biomeName = StringUtils.getOrDefault(biome.biomeName, MappingUtils.getClassName(biome));
String name = StringUtils.formatIdentifier(biomeName, true, !CraftPresence.CONFIG.advancedSettings.formatWords);
if (!DEFAULT_NAMES.contains(name)) {
DEFAULT_NAMES.add(name);
}
if (!BIOME_NAMES.contains(name)) {
BIOME_NAMES.add(name);
}
}
}
// N/A
}

@Override
Expand Down Expand Up @@ -251,21 +194,11 @@ public String getOverrideText(ModuleData data) {
return CraftPresence.CLIENT.getOverrideText(getPresenceData(data));
}

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

@Override
public boolean hasScannedInternals() {
return hasScannedInternals;
}

@Override
public void setScannedInternals(final boolean state) {
hasScannedInternals = state;
}

@Override
public boolean canFetchConfig() {
return CraftPresence.CONFIG != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
import com.gitlab.cdagaming.craftpresence.core.config.Config;
import com.gitlab.cdagaming.craftpresence.core.config.element.ModuleData;
import com.gitlab.cdagaming.craftpresence.core.impl.ExtendedModule;
import io.github.cdagaming.unicore.utils.FileUtils;
import io.github.cdagaming.unicore.utils.MappingUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.src.WorldProvider;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
import java.util.function.Supplier;
Expand Down Expand Up @@ -67,7 +63,7 @@ public class DimensionUtils implements ExtendedModule {
/**
* Whether this module has performed an initial retrieval of internal items
*/
private boolean hasScannedInternals = false;
private boolean hasScannedInternals = true;
/**
* Whether this module has performed an initial event sync
*/
Expand All @@ -88,10 +84,6 @@ public class DimensionUtils implements ExtendedModule {
* The alternative display name for the Current Dimension the Player is in, if any
*/
private String CURRENT_DIMENSION_IDENTIFIER;
/**
* The Player's Current Dimension, if any
*/
private WorldProvider CURRENT_DIMENSION;

@Override
public void clearFieldData() {
Expand All @@ -101,7 +93,6 @@ public void clearFieldData() {

@Override
public void clearAttributes() {
CURRENT_DIMENSION = null;
RAW_DIMENSION_NAME = null;
RAW_DIMENSION_IDENTIFIER = null;
CURRENT_DIMENSION_NAME = null;
Expand All @@ -114,16 +105,11 @@ public void clearAttributes() {

@Override
public void updateData() {
final WorldProvider newProvider = CraftPresence.world.worldProvider;
final String newDimensionName = MappingUtils.getClassName(newProvider);

final String newDimensionIdentifier = newDimensionName;

if (!newDimensionName.equals(RAW_DIMENSION_NAME) || !newDimensionIdentifier.equals(RAW_DIMENSION_IDENTIFIER)) {
CURRENT_DIMENSION = newProvider;
final String newDimensionName = "WorldProvider"; // Stub

RAW_DIMENSION_NAME = StringUtils.getOrDefault(newDimensionName, newDimensionIdentifier);
RAW_DIMENSION_IDENTIFIER = newDimensionIdentifier;
if (!newDimensionName.equals(RAW_DIMENSION_NAME) || !newDimensionName.equals(RAW_DIMENSION_IDENTIFIER)) {
RAW_DIMENSION_NAME = newDimensionName;
RAW_DIMENSION_IDENTIFIER = newDimensionName;
CURRENT_DIMENSION_NAME = StringUtils.formatIdentifier(RAW_DIMENSION_NAME, false, !CraftPresence.CONFIG.advancedSettings.formatWords);
CURRENT_DIMENSION_IDENTIFIER = StringUtils.formatIdentifier(RAW_DIMENSION_IDENTIFIER, true, !CraftPresence.CONFIG.advancedSettings.formatWords);

Expand All @@ -146,8 +132,6 @@ public void updateData() {
public void initPresence() {
syncArgument("dimension.default.icon", () -> CraftPresence.CONFIG.dimensionSettings.fallbackDimensionIcon);

syncArgument("data.dimension.instance", () -> CURRENT_DIMENSION);
syncArgument("data.dimension.class", () -> CURRENT_DIMENSION.getClass());
syncArgument("data.dimension.name", () -> RAW_DIMENSION_NAME, true);
syncArgument("data.dimension.identifier", () -> RAW_DIMENSION_IDENTIFIER, true);

Expand Down Expand Up @@ -178,50 +162,9 @@ public void updatePresence() {
// N/A
}

/**
* Retrieves a List of detected Dimension Types
*
* @return The detected Dimension Types found
*/
private List<WorldProvider> getDimensionTypes() {
List<WorldProvider> dimensionTypes = StringUtils.newArrayList();

if (dimensionTypes.isEmpty()) {
// 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);
}
}
}
}

return dimensionTypes;
}

@Override
public void getInternalData() {
for (WorldProvider TYPE : getDimensionTypes()) {
if (TYPE != null) {
String dimensionName = MappingUtils.getClassName(TYPE);
String name = StringUtils.formatIdentifier(dimensionName, true, !CraftPresence.CONFIG.advancedSettings.formatWords);
if (!DEFAULT_NAMES.contains(name)) {
DEFAULT_NAMES.add(name);
}
if (!DIMENSION_NAMES.contains(name)) {
DIMENSION_NAMES.add(name);
}
}
}
// N/A
}

@Override
Expand Down Expand Up @@ -251,21 +194,11 @@ public String getOverrideText(ModuleData data) {
return CraftPresence.CLIENT.getOverrideText(getPresenceData(data));
}

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

@Override
public boolean hasScannedInternals() {
return hasScannedInternals;
}

@Override
public void setScannedInternals(final boolean state) {
hasScannedInternals = state;
}

@Override
public boolean canFetchConfig() {
return CraftPresence.CONFIG != null;
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=2.5-a1.2.6
mc_mappings_type=mcp
mc_version=a1.2.6
mc_protocol=6
mc_mappings=a1.1.2_01
mc_mappings_type=retroMCP
mc_version=a1.1.2_01
mc_protocol=2
display_version=
# Fabric Info
fabric_loader_version=0.16.9
fabric_api_version=
fabric_game_version_range=*
fabric_loader_version_range=>=0.12.0
# Forge Info
forge_version=a1.2.6+build.2
forge_version=a1.1.2_01
fml_version_range=
forge_game_version_range=a1.2.6
forge_game_version_range=a1.1.2_01
forge_loader_version_range=
# Deployment Info
versionId=2.5.3
Expand Down

0 comments on commit 8104b0f

Please sign in to comment.