Skip to content

Commit

Permalink
[Port] Update to special/bta (v2.5.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed Nov 26, 2024
1 parent c6a0fcb commit 99c3e9f
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 263 deletions.
140 changes: 27 additions & 113 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.hypherionmc.modpublisher.plugin.ModPublisherGradleExtension
import xyz.wagyourtail.jvmdg.gradle.task.files.DowngradeFiles
import xyz.wagyourtail.replace_str.ProcessClasses
import xyz.wagyourtail.unimined.api.UniminedExtension
import xyz.wagyourtail.unimined.api.minecraft.patch.fabric.FabricLikePatcher
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask
import java.util.*

Expand Down Expand Up @@ -124,6 +125,9 @@ subprojects {
}

repositories {
flatDir {
dirs("$rootDir/libs")
}
mavenLocal()
mavenCentral()
// ModLoader Mavens
Expand Down Expand Up @@ -168,122 +172,32 @@ subprojects {

extensions.getByType<UniminedExtension>().minecraft(sourceSets.getByName("main"), true) {
side(if (isJarMod) "client" else "combined")
version(mcVersion)

mappings {
val mcMappings = "mc_mappings"()!!
when (mcMappingsType) {
"mcp" -> {
if (!isJarMod) {
searge()
}
mcp(if (isJarMod) "legacy" else "stable", mcMappings) {
if (!isJarMod) {
clearOutputs()
outputs("mcp", true) { listOf("intermediary") }
}
}
}

"forgeMCP" -> {
forgeBuiltinMCP("forge_version"()!!) {
clearContains()
clearOutputs()
contains({ _, t ->
!t.contains("MCP")
}) {
onlyExistingSrc()
outputs("searge", false) { listOf("official") }
}
contains({ _, t ->
t.contains("MCP")
}) {
outputs("mcp", true) { listOf("intermediary") }
sourceNamespace("searge")
}
}
officialMappingsFromJar {
clearContains()
clearOutputs()
outputs("official", false) { listOf() }
}
}

"retroMCP" -> {
retroMCP(mcMappings)
}
version("empty-$mcVersion")

"yarn" -> {
yarn(mcMappings)
}

"mojmap" -> {
mojmap {
skipIfNotIn("intermediary")
}
}

"parchment" -> {
mojmap {
skipIfNotIn("intermediary")
}
parchment(mcVersion, mcMappings)
}

else -> throw GradleException("Unknown or Unsupported Mappings version")
defaultRemapJar = false
val fabricData: FabricLikePatcher.() -> Unit = {
if (accessWidenerFile.exists()) {
accessWidener(accessWidenerFile)
}

// Only use Intermediaries on Versions that support it
val usingIntermediary = (isLegacy && protocol >= 39) || !isLegacy
if (usingIntermediary) {
if (isModern) {
intermediary()
} else {
legacyIntermediary()
}
}

// ability to add custom mappings
val target = if (!isModern) "mcp" else "mojmap"
stub.withMappings("searge", target) {
c("ModLoader", "net/minecraft/src/ModLoader", "net/minecraft/src/ModLoader")
c("BaseMod", "net/minecraft/src/BaseMod", "net/minecraft/src/BaseMod")
// Fix: Fixed an inconsistent mapping in 1.16 and 1.16.1 between MCP and Mojmap
if (!isLegacy && (protocol == 735 || protocol == 736)) {
c(
"dng",
listOf(
"net/minecraft/client/gui/widget/Widget",
"net/minecraft/client/gui/components/AbstractWidget"
)
) {
m("e", "()I", "func_238483_d_", "getHeightRealms")
}
}
loader("fabric_loader_version"()!!)
if (isJarMod) {
prodNamespace("official")
devMappings = null
}

if (isMCPJar) {
if (protocol <= 2) { // MC a1.1.2_01 and below
devNamespace("searge")
} else {
devFallbackNamespace("searge")
}
} else if (usingIntermediary) {
devFallbackNamespace("intermediary")
customIntermediaries = true
}
if (isModern) {
fabric(fabricData)
} else {
merged {
legacyFabric(fabricData)
jarMod {}
}
}

if (shouldDowngrade) {
val apiVersion = if (buildVersion.isJava7) JavaVersion.VERSION_1_8 else buildVersion
val downgradeClient = tasks.register("downgradeClient", DowngradeFiles::class.java) {
inputCollection = sourceSet.output.classesDirs + sourceSet.runtimeClasspath
classpath = project.files()
outputCollection.files
}

runs.config("client") {
classpath = downgradeClient.get().outputCollection + files(jvmdg.getDowngradedApi(apiVersion))
}
}
mappings {
devNamespace("official")
devFallbackNamespace("official")
}

minecraftRemapper.config {
Expand All @@ -306,7 +220,7 @@ subprojects {
"compileOnly"("com.github.spotbugs:spotbugs-annotations:4.8.6")

// Attach UniLib dependency
"modImplementation"(
"implementation"(
"com.gitlab.cdagaming.unilib:$libPrefix-${
libName.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(
Expand Down Expand Up @@ -436,7 +350,7 @@ subprojects {
jvmdg.debugSkipStubs.add(JavaVersion.VERSION_1_8)
}

val resultJar = tasks.getByName<RemapJarTask>("remapJar")
val resultJar = tasks.getByName<ShadowJar>("shadowJar")
val resultClassifier = resultJar.archiveClassifier.get()
resultJar.archiveClassifier.set("$resultClassifier-native")

Expand Down
19 changes: 3 additions & 16 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import xyz.wagyourtail.unimined.api.minecraft.patch.fabric.FabricLikePatcher
import java.util.regex.Pattern

/**
Expand All @@ -23,21 +22,7 @@ val mcVersionLabel: String by extra
val fileFormat: String by extra

unimined.minecraft {
defaultRemapJar = false
if (!isJarMod) {
val fabricData: FabricLikePatcher.() -> Unit = {
if (accessWidenerFile.exists()) {
accessWidener(accessWidenerFile)
}
loader("fabric_loader_version"()!!)
customIntermediaries = true
}
if (isModern) {
fabric(fabricData)
} else {
legacyFabric(fabricData)
}
}
// N/A
}

val shadeOnly: Configuration by configurations.creating
Expand All @@ -48,6 +33,8 @@ configurations.implementation.get().extendsFrom(shade)
configurations.runtimeOnly.get().extendsFrom()

dependencies {
"jarMod"("local:nsss:${"forge_version"()}")

// Legacy Dependencies, based on Protocol Version
if (isLegacy) {
if (protocol <= 61) { // MC 1.5.2 and below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import io.github.cdagaming.unicore.utils.OSUtils;
import io.github.cdagaming.unicore.utils.ScheduleUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Session;
import net.minecraft.src.World;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.player.Session;
import net.minecraft.core.world.World;

/**
* The Primary Application Class and Utilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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.src.GuiScreen;
import net.minecraft.client.gui.GuiScreen;

public class MainGui extends ConfigurationGui<Config> {
private final Config INSTANCE, DEFAULTS;
Expand Down Expand Up @@ -232,11 +232,11 @@ calc2, getButtonY(currentY),
}

@Override
protected void keyTyped(char typedChar, int keyCode) {
public void keyTyped(char typedChar, int keyCode, int mouseX, int mouseY) {
if (isEscapeKey(keyCode) && getCurrentData().hasChanged()) {
syncData();
}
super.keyTyped(typedChar, keyCode);
super.keyTyped(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.src.GuiScreen;
import net.minecraft.client.gui.GuiScreen;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
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.Entity;
import net.minecraft.src.EntityList;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.EntityDispatcher;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -127,8 +127,8 @@ public void clearAttributes() {

@Override
public void updateData() {
final Entity NEW_CURRENT_TARGET = CraftPresence.instance.objectMouseOver != null && CraftPresence.instance.objectMouseOver.entityHit != null ? CraftPresence.instance.objectMouseOver.entityHit : null;
final Entity NEW_CURRENT_RIDING = CraftPresence.player.ridingEntity;
final Entity NEW_CURRENT_TARGET = CraftPresence.instance.objectMouseOver != null && CraftPresence.instance.objectMouseOver.entity != null ? CraftPresence.instance.objectMouseOver.entity : null;
final Entity NEW_CURRENT_RIDING = CraftPresence.player.vehicle;

final boolean hasTargetChanged = !Objects.equals(NEW_CURRENT_TARGET, CURRENT_TARGET);
final boolean hasRidingChanged = !Objects.equals(NEW_CURRENT_RIDING, CURRENT_RIDING);
Expand Down Expand Up @@ -257,7 +257,7 @@ public void updatePresence() {

@Override
public void getInternalData() {
final Map mappings = (Map) StringUtils.getField(EntityList.class, null, "classToStringMapping", "field_1610_b", "b");
final Map mappings = (Map) StringUtils.getField(EntityDispatcher.class, null, "classToStringMapping", "field_1610_b", "b");
if (!mappings.values().isEmpty()) {
for (Object entityLocationObj : mappings.values()) {
final String entityLocation = (String) entityLocationObj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.gitlab.cdagaming.unilib.ModUtils;
import com.gitlab.cdagaming.unilib.utils.ItemUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.core.block.Block;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;

import java.util.List;
import java.util.Map;
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.src.GuiScreen;
import net.minecraft.src.GuiContainer;
import net.minecraft.client.gui.GuiContainer;
import net.minecraft.client.gui.GuiScreen;
import unilib.external.io.github.classgraph.ClassInfo;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import io.github.cdagaming.unicore.utils.MappingUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.src.ItemStack;
import net.minecraft.core.item.ItemStack;
import unilib.external.io.github.classgraph.ClassInfo;

import javax.annotation.Nonnull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private void checkCommands() {
}

@Override
protected void keyTyped(char typedChar, int keyCode) {
public void keyTyped(char typedChar, int keyCode, int mouseX, int mouseY) {
if (!blockInteractions) {
if (commandInput.isControlFocused()) {
if (isEscapeKey(keyCode)) {
Expand All @@ -503,7 +503,7 @@ protected void keyTyped(char typedChar, int keyCode) {
}
}
}
super.keyTyped(typedChar, keyCode);
super.keyTyped(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.src.GuiScreen;
import net.minecraft.client.gui.GuiScreen;

import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import io.github.cdagaming.unicore.utils.MathUtils;
import io.github.cdagaming.unicore.utils.StringUtils;
import io.github.cdagaming.unicore.utils.TimeUtils;
import net.minecraft.src.*;
import net.minecraft.client.gui.GuiConnecting;
import net.minecraft.client.net.handler.NetClientHandler;
import net.minecraft.core.net.NetworkManager;

import java.net.Socket;
import java.util.List;
Expand Down Expand Up @@ -586,9 +588,9 @@ private void joinServer(final ServerNBTStorage serverData) {
@Override
public void initPresence() {
// Player Position Arguments
syncArgument("player.position.x", () -> MathUtils.roundDouble(CraftPresence.player.posX, 3));
syncArgument("player.position.y", () -> MathUtils.roundDouble(CraftPresence.player.posY, 3));
syncArgument("player.position.z", () -> MathUtils.roundDouble(CraftPresence.player.posZ, 3));
syncArgument("player.position.x", () -> MathUtils.roundDouble(CraftPresence.player.x, 3));
syncArgument("player.position.y", () -> MathUtils.roundDouble(CraftPresence.player.y, 3));
syncArgument("player.position.z", () -> MathUtils.roundDouble(CraftPresence.player.z, 3));

// Player Health Arguments
syncArgument("player.health.current", () -> MathUtils.roundDouble(CraftPresence.player.health, 0));
Expand All @@ -607,7 +609,7 @@ public void initPresence() {
return StringUtils.getOrDefault(newWeatherName);
});
syncArgument("world.name", () -> {
final String primaryWorldName = CraftPresence.world.getWorldInfo().getWorldName();
final String primaryWorldName = CraftPresence.world.getLevelData().getWorldName();
final String secondaryWorldName = Constants.TRANSLATOR.translate("craftpresence.defaults.world_name");
final String newWorldName = StringUtils.getOrDefault(primaryWorldName, secondaryWorldName);
return StringUtils.getOrDefault(newWorldName);
Expand Down
Loading

0 comments on commit 99c3e9f

Please sign in to comment.