Skip to content

Commit

Permalink
Merge pull request #81 from Gaming32/port/1.21
Browse files Browse the repository at this point in the history
Port to 1.21
  • Loading branch information
Gaming32 authored Jun 18, 2024
2 parents fa1f322 + e0d4406 commit 4b0789e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 21 deletions.
28 changes: 16 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id("io.github.gaming32.gradle.preprocess-root") version "0.4.4"
id("xyz.wagyourtail.unimined") version "1.2.4" apply false
id("xyz.wagyourtail.unimined") version "1.2.9" apply false
}

repositories {
mavenCentral()
}

preprocess {
val fabric12100 = createNode("1.21-fabric", 1_21_00, "yarn")
val neoforge12100 = createNode("1.21-neoforge", 1_21_00, "yarn")
val fabric12006 = createNode("1.20.6-fabric", 1_20_06, "yarn")
val neoforge12006 = createNode("1.20.6-neoforge", 1_20_06, "yarn")
val fabric12004 = createNode("1.20.4-fabric", 1_20_04, "yarn")
Expand All @@ -21,15 +23,17 @@ preprocess {
val fabric11802 = createNode("1.18.2-fabric", 1_18_02, "yarn")
val forge11802 = createNode("1.18.2-forge", 1_18_02, "srg")

fabric12006.link(neoforge12006)
neoforge12006.link(neoforge12004)
neoforge12004.link(fabric12004)
fabric12004.link(fabric12001)
fabric12001.link(forge12001)
forge12001.link(forge11904)
forge11904.link(fabric11904)
fabric11904.link(fabric11902)
fabric11902.link(forge11902)
forge11902.link(forge11802)
forge11802.link(fabric11802)
fabric12100.link(neoforge12100)
neoforge12100.link(neoforge12006)
neoforge12006.link(fabric12006)
fabric12006.link(fabric12004)
fabric12004.link(neoforge12004)
neoforge12004.link(forge12001)
forge12001.link(fabric12001)
fabric12001.link(fabric11904)
fabric11904.link(forge11904)
forge11904.link(forge11902)
forge11902.link(fabric11902)
fabric11902.link(fabric11802)
fabric11802.link(forge11802)
}
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ listOf(
"1.20.4-fabric",
"1.20.6-neoforge",
"1.20.6-fabric",
"1.21-neoforge",
"1.21-fabric",
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
25 changes: 23 additions & 2 deletions src/main/java/io/github/gaming32/worldhost/ResourceLocations.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,35 @@
import net.minecraft.resources.ResourceLocation;

public final class ResourceLocations {
private static final String WORLD_HOST_NAMESPACE = "world-host";
//#if MC >= 1.19.4
private static final ResourceLocation WORLD_HOST_TEMPLATE = namespaced(WORLD_HOST_NAMESPACE, "");
//#endif

private ResourceLocations() {
}

public static ResourceLocation minecraft(String path) {
return new ResourceLocation(ResourceLocation.DEFAULT_NAMESPACE, path);
//#if MC >= 1.21
return ResourceLocation.withDefaultNamespace(path);
//#else
//$$ return new ResourceLocation(ResourceLocation.DEFAULT_NAMESPACE, path);
//#endif
}

public static ResourceLocation worldHost(String path) {
return new ResourceLocation("world-host", path);
//#if MC >= 1.19.4
return WORLD_HOST_TEMPLATE.withPath(path);
//#else
//$$ return new ResourceLocation(WORLD_HOST_NAMESPACE, path);
//#endif
}

public static ResourceLocation namespaced(String namespace, String path) {
//#if MC >= 1.21
return ResourceLocation.fromNamespaceAndPath(namespace, path);
//#else
//$$ return new ResourceLocation(namespace, path);
//#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ private void toastRender(CallbackInfo ci) {
//#else
new GuiGraphics(minecraft, renderBuffers.bufferSource()),
//#endif
mouseX, mouseY, minecraft.getFrameTime()
mouseX, mouseY,
//#if MC >= 1.21
minecraft.getTimer().getRealtimeDeltaTicks()
//#else
//$$ minecraft.getFrameTime()
//#endif
);
}
//#endif
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ side = "BOTH"
[[dependencies.world_host]]
modId = "minecraft"
##if MC == 1.20.6
versionRange = "[1.20.5,1.20.7)"
#?? versionRange = "[1.20.5,1.20.7)"
##else
#?? versionRange = "[$mc_version]"
versionRange = "[$mc_version]"
##endif
type = "required"
ordering = "NONE"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
//#elseif MC == 1.20.4
//?? "minecraft": ">=1.20.3- <1.20.5",
//#elseif MC == 1.20.6
"minecraft": ">=1.20.5- <1.20.7",
//?? "minecraft": ">=1.20.5- <1.20.7",
//#else
//?? "minecraft": "$mc_version",
"minecraft": "$mc_version",
//#endif
"fabric-resource-loader-v0": "*"
},
Expand Down
6 changes: 5 additions & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ unimined.minecraft {
})
mixinConfig("world-host.mixins.json")
}
isNeoForge -> neoForged {
isNeoForge -> neoForge {
loader(when (mcVersion) {
1_21_00 -> "4-beta"
1_20_06 -> "21-beta"
1_20_04 -> "69-beta"
else -> throw IllegalStateException("Unknown NeoForge version for $mcVersionString")
Expand Down Expand Up @@ -259,6 +260,7 @@ dependencies {

if (isFabric) {
when (mcVersion) {
1_21_00 -> "11.0.0-beta.1"
1_20_06 -> "10.0.0-beta.1"
1_20_04 -> "9.0.0"
1_20_01 -> "7.2.2"
Expand All @@ -280,6 +282,7 @@ dependencies {

if (isFabric) {
when (mcVersion) {
1_21_00 -> "0.100.1+1.21"
1_20_06 -> "0.100.0+1.20.6"
1_20_04 -> "0.97.1+1.20.4"
1_20_01 -> "0.92.2+1.20.1"
Expand Down Expand Up @@ -381,6 +384,7 @@ tasks.processResources {
// TODO: Remove pack.mcmeta in 1.20.4
filesMatching("pack.mcmeta") {
expand("pack_format" to when {
mcVersion >= 1_21_00 -> 34
mcVersion >= 1_20_05 -> 32
mcVersion >= 1_20_03 -> 22
mcVersion >= 1_20_02 -> 18
Expand Down
2 changes: 1 addition & 1 deletion versions/mainProject
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.6-fabric
1.21-fabric

0 comments on commit 4b0789e

Please sign in to comment.