Skip to content

Commit

Permalink
Update Fabric/NeoForge to MC 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed Apr 29, 2024
1 parent 8af5bc5 commit 660c10e
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 100 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ subprojects {
pluginDescription = 'spark is a performance profiling plugin/mod for Minecraft clients, servers and proxies.'
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release = 8
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand All @@ -12,7 +13,6 @@ pluginManagement {
name = 'NeoForge'
url = 'https://maven.neoforged.net/releases'
}
gradlePluginPortal()
}
}

Expand Down
2 changes: 1 addition & 1 deletion spark-bukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion spark-bungeecord/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
8 changes: 4 additions & 4 deletions spark-fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import net.fabricmc.loom.task.RemapJarTask

plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

tasks.withType(JavaCompile) {
Expand All @@ -28,8 +28,8 @@ configurations {

dependencies {
// https://modmuss50.me/fabric.html
minecraft 'com.mojang:minecraft:1.20.5'
mappings 'net.fabricmc:yarn:1.20.5+build.1:v2'
minecraft 'com.mojang:minecraft:1.20.6'
mappings 'net.fabricmc:yarn:1.20.6+build.1:v2'
modImplementation 'net.fabricmc:fabric-loader:0.15.10'

Set<String> apiModules = [
Expand All @@ -40,7 +40,7 @@ dependencies {

// Add each module as a dependency
apiModules.forEach {
modImplementation(fabricApi.module(it, '0.97.5+1.20.5'))
modImplementation(fabricApi.module(it, '0.97.8+1.20.6'))
}

include(modImplementation('me.lucko:fabric-permissions-api:0.3.1'))
Expand Down
2 changes: 1 addition & 1 deletion spark-forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

Expand Down
2 changes: 1 addition & 1 deletion spark-minestom/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

tasks.withType(JavaCompile) {
Expand Down
22 changes: 13 additions & 9 deletions spark-neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'net.neoforged.gradle.userdev' version '7.0.97'
id 'io.github.goooler.shadow' version '8.1.7'
id 'net.neoforged.gradle.userdev' version '7.0.105'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
tasks.withType(JavaCompile).configureEach {
// override, compile targeting J21
options.release = 21
}

tasks.withType(JavaCompile) {
// override, compile targeting J17
options.release = 17
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

minecraft {
Expand All @@ -22,21 +26,21 @@ configurations {
}

dependencies {
implementation "net.neoforged:neoforge:20.4.223"
implementation "net.neoforged:neoforge:20.6.1-beta"
shade project(':spark-common')
}

processResources {
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
include 'META-INF/neoforge.mods.toml'
expand (
'pluginVersion': project.pluginVersion,
'pluginDescription': project.pluginDescription
)
}

from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
exclude 'META-INF/neoforge.mods.toml'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.commands.CommandSource;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component.Serializer;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.MinecraftServer;
Expand Down Expand Up @@ -65,7 +66,7 @@ public UUID getUniqueId() {

@Override
public void sendMessage(Component message) {
MutableComponent component = Serializer.fromJson(GsonComponentSerializer.gson().serializeToTree(message));
MutableComponent component = Serializer.fromJson(GsonComponentSerializer.gson().serializeToTree(message), RegistryAccess.EMPTY);
Objects.requireNonNull(component, "component");
super.delegate.sendSystemMessage(component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public NeoForgeSparkMod(IEventBus eventBus) {
eventBus.addListener(this::setup);
eventBus.addListener(this::clientInit);
NeoForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true));
}

public String getVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,35 @@
import me.lucko.spark.common.tick.AbstractTickHook;
import me.lucko.spark.common.tick.TickHook;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;

public class NeoForgeTickHook extends AbstractTickHook implements TickHook {
private final TickEvent.Type type;

public NeoForgeTickHook(TickEvent.Type type) {
this.type = type;
public abstract class NeoForgeTickHook extends AbstractTickHook implements TickHook {
@Override
public void start() {
NeoForge.EVENT_BUS.register(this);
}

@SubscribeEvent
public void onTick(TickEvent.ServerTickEvent e) {
if (e.phase != TickEvent.Phase.START) {
return;
}

if (e.type != this.type) {
return;
}

onTick();
@Override
public void close() {
NeoForge.EVENT_BUS.unregister(this);
}

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent e) {
if (e.phase != TickEvent.Phase.START) {
return;
}
public static final class Server extends NeoForgeTickHook {

if (e.type != this.type) {
return;
@SubscribeEvent
public void onTickStart(ServerTickEvent.Pre e) {
onTick();
}

onTick();
}

public static final class Client extends NeoForgeTickHook {

@Override
public void start() {
NeoForge.EVENT_BUS.register(this);
}

@Override
public void close() {
NeoForge.EVENT_BUS.unregister(this);
@SubscribeEvent
public void onTickStart(ClientTickEvent.Pre e) {
onTick();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,11 @@
import me.lucko.spark.common.tick.SimpleTickReporter;
import me.lucko.spark.common.tick.TickReporter;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;

public class NeoForgeTickReporter extends SimpleTickReporter implements TickReporter {
private final TickEvent.Type type;

public NeoForgeTickReporter(TickEvent.Type type) {
this.type = type;
}

@SubscribeEvent
public void onTick(TickEvent.ServerTickEvent e) {
if (e.type != this.type) {
return;
}

switch (e.phase) {
case START -> onStart();
case END -> onEnd();
default -> throw new AssertionError(e.phase);
}
}
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent e) {
if (e.type != this.type) {
return;
}

switch (e.phase) {
case START -> onStart();
case END -> onEnd();
default -> throw new AssertionError(e.phase);
}
}
public abstract class NeoForgeTickReporter extends SimpleTickReporter implements TickReporter {

@Override
public void start() {
Expand All @@ -69,4 +40,30 @@ public void close() {
super.close();
}

public static final class Server extends NeoForgeTickReporter {

@SubscribeEvent
public void onTickStart(ServerTickEvent.Pre e) {
onStart();
}

@SubscribeEvent
public void onTickEnd(ServerTickEvent.Post e) {
onEnd();
}
}

public static final class Client extends NeoForgeTickReporter {

@SubscribeEvent
public void onTickStart(ClientTickEvent.Pre e) {
onStart();
}

@SubscribeEvent
public void onTickEnd(ClientTickEvent.Post e) {
onEnd();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;

import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
Expand Down Expand Up @@ -123,12 +122,12 @@ public ThreadDumper getDefaultThreadDumper() {

@Override
public TickHook createTickHook() {
return new NeoForgeTickHook(TickEvent.Type.CLIENT);
return new NeoForgeTickHook.Client();
}

@Override
public TickReporter createTickReporter() {
return new NeoForgeTickReporter(TickEvent.Type.CLIENT);
return new NeoForgeTickReporter.Client();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.server.ServerAboutToStartEvent;
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import net.neoforged.neoforge.server.permission.PermissionAPI;
Expand Down Expand Up @@ -226,12 +225,12 @@ public ThreadDumper getDefaultThreadDumper() {

@Override
public TickHook createTickHook() {
return new NeoForgeTickHook(TickEvent.Type.SERVER);
return new NeoForgeTickHook.Server();
}

@Override
public TickReporter createTickReporter() {
return new NeoForgeTickReporter(TickEvent.Type.SERVER);
return new NeoForgeTickReporter.Server();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion spark-nukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion spark-sponge7/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'net.kyori.blossom' version '1.3.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion spark-sponge8/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion spark-velocity/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'net.kyori.blossom' version '1.3.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion spark-velocity4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'net.kyori.blossom' version '1.3.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

tasks.withType(JavaCompile) {
Expand Down
2 changes: 1 addition & 1 deletion spark-waterdog/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.github.goooler.shadow' version '8.1.7'
}

tasks.withType(JavaCompile) {
Expand Down

0 comments on commit 660c10e

Please sign in to comment.