Skip to content

Commit

Permalink
Update to Minecraft 1.20.6 (Forge doesn't work)
Browse files Browse the repository at this point in the history
  • Loading branch information
YaLTeR committed May 1, 2024
1 parent 416a7af commit fa76861
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
java-version: 21

- name: Build (Forge)
run: ./gradlew build
Expand Down
10 changes: 5 additions & 5 deletions build-fabric.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
}

def minecraftVersion = "1.20.4" // Used for output JAR filenames.
def minecraftVersion = "1.20.6" // Used for output JAR filenames.

version = project.mod_version
group = "yalter.mousetweaks"
archivesBaseName = "MouseTweaks-fabric-mc${minecraftVersion}"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

repositories {
maven {
Expand Down Expand Up @@ -36,10 +36,10 @@ loom {
dependencies {
minecraft "com.mojang:minecraft:${minecraftVersion}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:0.15.9"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.96.11+1.20.4"
modImplementation "net.fabricmc:fabric-loader:0.15.10"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.97.8+1.20.6"

modImplementation 'com.terraformersmc:modmenu:9.0.0'
modImplementation 'com.terraformersmc:modmenu:10.0.0-beta.1'
}

processResources {
Expand Down
23 changes: 6 additions & 17 deletions build-neoforge.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.80'
id 'net.neoforged.gradle.userdev' version '7.0.109'
}

def minecraftVersion = "1.20.4" // Used for output JAR filenames.
def minecraftVersion = "1.20.6" // Used for output JAR filenames.

version = project.mod_version
group = "yalter.mousetweaks"
Expand All @@ -15,7 +15,7 @@ base {
archivesName = "MouseTweaks-neoforge-mc${minecraftVersion}"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

sourceSets {
main {
Expand All @@ -27,25 +27,14 @@ sourceSets {

resources {
exclude 'fabric.mod.json'
exclude 'META-INF/mods-neo.toml'
exclude 'META-INF/mods.toml'
}
}
}

tasks.register("fixModsToml", Copy) {
// Copy the mods-neo.toml file to mods.toml
from "src/main/resources/META-INF"
include "mods-neo.toml"
rename "mods-neo.toml", "mods.toml"
into "src/main/resources/META-INF"
}

// Make the fixModsToml task run before the processResources task
processResources.dependsOn(fixModsToml)

processResources {
inputs.property "version", project.mod_version
filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.mod_version
}
}
Expand All @@ -69,7 +58,7 @@ runs {
}

dependencies {
implementation "net.neoforged:neoforge:20.4.190"
implementation "net.neoforged:neoforge:20.6.11-beta"
}

task srcJar(type: Jar) {
Expand Down
21 changes: 5 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'

def minecraftVersion = "1.20.2" // Used for output JAR filenames.
def minecraftVersion = "1.20.6" // Used for output JAR filenames.

version = project.mod_version
group = "yalter.mousetweaks"
base.archivesName = "MouseTweaks-forge-mc${minecraftVersion}"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

sourceSets {
main {
Expand All @@ -29,7 +29,7 @@ sourceSets {

resources {
exclude 'fabric.mod.json'
exclude 'META-INF/mods-neo.toml'
exclude 'META-INF/neoforge.mods.toml'
}
}
}
Expand All @@ -40,7 +40,7 @@ mixin {
}

minecraft {
mappings channel: 'official', version: '1.20.2'
mappings channel: 'official', version: '1.20.6'

runs {
client {
Expand Down Expand Up @@ -71,17 +71,6 @@ minecraft {
}
}

tasks.register("fixModsToml", Copy) {
// Copy the mods-forge.toml file to mods.toml
from "src/main/resources/META-INF"
include "mods-forge.toml"
rename "mods-forge.toml", "mods.toml"
into "src/main/resources/META-INF"
}

// Make the fixModsToml task run before the processResources task
processResources.dependsOn(fixModsToml)

processResources {
inputs.property "version", project.mod_version
filesMatching("META-INF/mods.toml") {
Expand All @@ -90,7 +79,7 @@ processResources {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.20.2-48.0.13'
minecraft 'net.minecraftforge:forge:1.20.6-50.0.0'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/yalter/mousetweaks/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void onClose() {

@Override
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
this.renderDirtBackground(guiGraphics);
this.renderBackground(guiGraphics, i, j, f);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 0xFFFFFF);
super.render(guiGraphics, i, j, f);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/yalter/mousetweaks/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import yalter.mousetweaks.handlers.IMTModGuiContainer3ExHandler;

import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -555,7 +554,7 @@ private static IGuiScreenHandler findHandler(Screen currentScreen) {
// Returns true if we can put items from one stack into another.
// This is different from ItemStack.areItemsEqual() because here empty stacks are compatible with anything.
private static boolean areStacksCompatible(ItemStack a, ItemStack b) {
return a.isEmpty() || b.isEmpty() || (ItemStack.isSameItem(a, b) && ItemStack.isSameItemSameTags(a, b));
return a.isEmpty() || b.isEmpty() || (ItemStack.isSameItem(a, b) && ItemStack.isSameItemSameComponents(a, b));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class MixinMouseHandler {

@SuppressWarnings("target")
@Dynamic("Lambda that calls screen.mouseDragged()")
@Inject(method = "method_1602(Lnet/minecraft/client/gui/screens/Screen;DDDD)V", at = @At("HEAD"), cancellable = true)
@Inject(method = "method_55795(Lnet/minecraft/client/gui/screens/Screen;DDDD)V", at = @At("HEAD"), cancellable = true)
private void onMouseDragged(Screen screen, double x, double y, double dx, double dy, CallbackInfo ci) {
MouseButton button = MouseButton.fromEventButton(this.activeButton);
if (button != null) {
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/yalter/mousetweaks/neoforge/ClientHelper.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package yalter.mousetweaks.neoforge;

import net.neoforged.neoforge.client.ConfigScreenHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import yalter.mousetweaks.ConfigScreen;

/**
* Functions accessing client-only classes, extracted so that they can be called from MouseTweaksNeo
* without causing class-loading errors on the server.
*/
public class ClientHelper {
public static ConfigScreenHandler.ConfigScreenFactory createConfigScreenFactory() {
return new ConfigScreenHandler.ConfigScreenFactory((minecraft, screen) -> new ConfigScreen(screen));
public class ClientHelper implements IConfigScreenFactory {
@Override
public Screen createScreen(Minecraft minecraft, Screen screen) {
return new ConfigScreen(screen);
}
}
6 changes: 2 additions & 4 deletions src/main/java/yalter/mousetweaks/neoforge/MouseTweaksNeo.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package yalter.mousetweaks.neoforge;

import net.neoforged.neoforge.client.ConfigScreenHandler;
import net.neoforged.neoforge.client.event.ScreenEvent.MouseButtonPressed;
import net.neoforged.neoforge.client.event.ScreenEvent.MouseButtonReleased;
import net.neoforged.neoforge.client.event.ScreenEvent.MouseDragged;
import net.neoforged.neoforge.client.event.ScreenEvent.MouseScrolled;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.common.Mod;
Expand All @@ -19,7 +18,6 @@
@Mod(Constants.MOD_ID)
public class MouseTweaksNeo {
public MouseTweaksNeo() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "ANY", (remote, isServer) -> true));
if (FMLEnvironment.dist != net.neoforged.api.distmarker.Dist.CLIENT) {
Logger.Log("Disabled because not running on the client.");
return;
Expand All @@ -28,7 +26,7 @@ public MouseTweaksNeo() {
Main.initialize();
NeoForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, ClientHelper::createConfigScreenFactory);
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, ClientHelper::new);
}

@SubscribeEvent
Expand Down
16 changes: 0 additions & 16 deletions src/main/resources/META-INF/mods-forge.toml

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"mousetweaks-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.15.9",
"fabricloader": ">=0.15.10",
"fabric-api": "*",
"minecraft": "~1.20.4",
"java": ">=17"
"minecraft": "~1.20.6",
"java": ">=21"
},
"suggests": {}
}
2 changes: 1 addition & 1 deletion src/main/resources/mousetweaks-fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "yalter.mousetweaks.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [],
"client": [
"MixinMouseHandler"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mousetweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "yalter.mousetweaks.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [],
"client": [
"AbstractContainerScreenAccessor"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "Mouse Tweaks Resources",
"pack_format": 15
"pack_format": 32
}
}

0 comments on commit fa76861

Please sign in to comment.