Skip to content

Commit

Permalink
Port to Minecraft 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Estecka committed Apr 25, 2024
1 parent 4c29e92 commit 6182d0f
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Minimum supported by target version of Minecraft
21, # Current LTS & minimum supported by Minecraft
]
runs-on: ubuntu-22.04
steps:
Expand All @@ -32,7 +32,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ matrix.java == '17' }} # Only upload artifacts built from latest java
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -57,7 +57,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -66,8 +66,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand All @@ -79,7 +79,8 @@ jar {
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.7
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10

#Fabric api
fabric_version=0.91.0+1.20.1
fabric_version=0.97.6+1.20.5

# Mod Properties
mod_version=1.2.2
Expand All @@ -18,4 +18,4 @@ archives_base_name=packrule-menus

# Optional Dependencies
clothGamerules_version=1.0.0+1.19.4
cloth_version=11.1.118
cloth_version=14.0.126
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
14 changes: 9 additions & 5 deletions src/main/java/tk/estecka/packrulemenus/GenericWarningScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.WarningScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.DirectionalLayoutWidget;
import net.minecraft.client.gui.widget.LayoutWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;

Expand Down Expand Up @@ -37,11 +39,13 @@ static public GenericWarningScreen VanillaWarning(BooleanConsumer onConfirm){
}

@Override
protected void initButtons(int yOffset){
this.proceedButton = ButtonWidget.builder(ScreenTexts.PROCEED, this::OnAccept).dimensions(this.width / 2 - 155 , 100 + yOffset, 150, 20).build();
this.cancelButton = ButtonWidget.builder(ScreenTexts.CANCEL, this::OnCancel).dimensions(this.width / 2 - 155 + 160, 100 + yOffset, 150, 20).build();
this.addDrawableChild(proceedButton);
this.addDrawableChild(cancelButton);
protected LayoutWidget getLayout(){
DirectionalLayoutWidget layout = DirectionalLayoutWidget.horizontal().spacing(8);
this.proceedButton = ButtonWidget.builder(ScreenTexts.PROCEED, this::OnAccept).build();
this.cancelButton = ButtonWidget.builder(ScreenTexts.CANCEL, this::OnCancel).build();
layout.add(proceedButton);
layout.add(cancelButton);
return layout;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@Mixin(MinecraftServer.class)
public interface IMinecraftServerMixin
{
@Invoker static public DataPackSettings callCreateDataPackSettings(ResourcePackManager manager){ throw new AssertionError(); }
@Invoker static public DataPackSettings callCreateDataPackSettings(ResourcePackManager manager, boolean allowEnabling){ throw new AssertionError(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.llamalad7.mixinextras.sugar.Local;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
Expand Down Expand Up @@ -42,7 +41,7 @@ abstract public class OptionScreenMixin

private IntegratedServer server;

@Inject( method="init", at=@At(value="INVOKE", ordinal=1, shift=Shift.AFTER, target="net/minecraft/client/gui/widget/GridWidget$Adder.add (Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;") )
@Inject( method="init", at=@At(value="INVOKE", ordinal=0, target="net/minecraft/client/gui/widget/GridWidget$Adder.add (Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;") )
private void gameruleMenu$Init(CallbackInfo info, @Local GridWidget.Adder adder){
this.server = this.client.getServer();

Expand All @@ -60,7 +59,7 @@ abstract public class OptionScreenMixin
)
));

var rollback = server.getDataPackManager().getEnabledNames();
var rollback = server.getDataPackManager().getEnabledIds();
adder.add(createButton(
Text.translatable("selectWorld.dataPacks"),
() -> new PackScreen(
Expand Down Expand Up @@ -119,14 +118,14 @@ private void ApplyFlags(final ResourcePackManager manager){
featureNames += id.toString()+", ";
PackRuleMenus.LOGGER.info("Reloading packs with features: {}", featureNames);

server.getSaveProperties().updateLevelInfo(new DataConfiguration(IMinecraftServerMixin.callCreateDataPackSettings(manager), features));
server.getSaveProperties().updateLevelInfo(new DataConfiguration(IMinecraftServerMixin.callCreateDataPackSettings(manager, true), features));
}


private void ReloadPacks(final ResourcePackManager manager){
client.inGameHud.getChatHud().addMessage(Text.translatable("commands.reload.success"));

server.reloadResources(manager.getEnabledNames()).exceptionally(e -> {
server.reloadResources(manager.getEnabledIds()).exceptionally(e -> {
PackRuleMenus.LOGGER.error("{}", e);
client.inGameHud.getChatHud().addMessage(Text.translatable("commands.reload.failure").formatted(Formatting.RED));
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"packrule-menus.mixins.json"
],
"depends": {
"minecraft": ">=1.20.0 <1.20.5",
"fabricloader": ">=0.15.3",
"java": ">=17"
"minecraft": "^1.20.5",
"fabricloader": ">=0.15.10",
"java": ">=21"
}
}

0 comments on commit 6182d0f

Please sign in to comment.