Skip to content

Commit

Permalink
Updated to 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Benonardo committed Dec 2, 2021
1 parent e24d765 commit 47363fc
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
11 changes: 4 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -27,10 +27,7 @@ processResources {
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"

def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
it.options.release = 17
}

java {
Expand Down
10 changes: 3 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.47
loader_version=0.11.1
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.8

# Mod Properties
mod_version = 1.0
maven_group = me.jaackson
archives_base_name = spu

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.29.4+1.16
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package me.jaackson.spu.mixin;

import net.minecraft.client.resource.ClientBuiltinResourcePackProvider;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackCompatibility;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackSource;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.function.Supplier;
import java.io.File;
import java.util.concurrent.CompletableFuture;

@Mixin(ClientBuiltinResourcePackProvider.class)
public class ClientBuiltinResourcePackProviderMixin {

@Redirect(at = @At("NEW"), method = "loadServerPack")
private ResourcePackProfile unlockServerPack(String name, boolean alwaysEnabled, Supplier<ResourcePack> packFactory, Text displayName, Text description, ResourcePackCompatibility compatibility, ResourcePackProfile.InsertionPosition direction, boolean pinned, ResourcePackSource source) {
return new ResourcePackProfile(name, alwaysEnabled, packFactory, displayName, description, compatibility, direction, false, source);

@Shadow private @Nullable ResourcePackProfile serverContainer;

@Inject(at = @At("TAIL"), method = "loadServerPack")
private void unlockServerPack(File packZip, ResourcePackSource packSource, CallbackInfoReturnable<CompletableFuture<Void>> cir) {
this.serverContainer = new ResourcePackProfile(serverContainer.getName(), serverContainer.isAlwaysEnabled(), ((ResourcePackProfileAccessor)serverContainer).accessPackFactory(), serverContainer.getDisplayName(), serverContainer.getDescription(), serverContainer.getCompatibility(), serverContainer.getInitialPosition(), false, serverContainer.getSource());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.jaackson.spu.mixin;

import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackProfile;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.function.Supplier;

@Mixin(ResourcePackProfile.class)
public interface ResourcePackProfileAccessor {

@Accessor("packFactory")
Supplier<ResourcePack> accessPackFactory();

}
5 changes: 3 additions & 2 deletions src/main/resources/spu.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"required": true,
"minVersion": "0.8",
"package": "me.jaackson.spu.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_17",
"client": [
"ClientBuiltinResourcePackProviderMixin"
"ClientBuiltinResourcePackProviderMixin",
"ResourcePackProfileAccessor"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 47363fc

Please sign in to comment.