Initial NeoForge port
Gets into world with no other mods. Currently nukes a bunch of API calls.
This commit is contained in:
18
build.gradle
18
build.gradle
@@ -1,5 +1,8 @@
|
|||||||
|
import net.fabricmc.loom.task.RemapJarTask
|
||||||
|
import net.fabricmc.loom.util.aw2at.Aw2At
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.7.3'
|
id("xyz.jpenilla.quiet-architectury-loom") version "1.7-SNAPSHOT"
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'io.github.goooler.shadow' version '8.1.8'
|
id 'io.github.goooler.shadow' version '8.1.8'
|
||||||
}
|
}
|
||||||
@@ -30,6 +33,10 @@ repositories {
|
|||||||
includeModule("ca.spottedleaf", "concurrentutil")
|
includeModule("ca.spottedleaf", "concurrentutil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.implementation {
|
configurations.implementation {
|
||||||
@@ -39,7 +46,8 @@ configurations.implementation {
|
|||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings loom.officialMojangMappings()
|
mappings loom.officialMojangMappings()
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
// modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
neoForge 'net.neoforged:neoforge:21.0.153'
|
||||||
|
|
||||||
shadow('ca.spottedleaf:concurrentutil:0.0.2-SNAPSHOT')
|
shadow('ca.spottedleaf:concurrentutil:0.0.2-SNAPSHOT')
|
||||||
shadow('org.yaml:snakeyaml:2.2')
|
shadow('org.yaml:snakeyaml:2.2')
|
||||||
@@ -48,7 +56,7 @@ dependencies {
|
|||||||
processResources {
|
processResources {
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
filesMatching("META-INF/neoforge.mods.toml") {
|
||||||
expand "version": project.version, "minecraft_version": minecraft_version, "loader_version": loader_version, "mod_version": mod_version
|
expand "version": project.version, "minecraft_version": minecraft_version, "loader_version": loader_version, "mod_version": mod_version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,9 +97,8 @@ jar {
|
|||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveClassifier = "dev-all"
|
archiveClassifier = "dev-all"
|
||||||
destinationDirectory = layout.buildDirectory.dir("devlibs")
|
destinationDirectory = layout.buildDirectory.dir("libs")
|
||||||
configurations = [project.configurations.shadow]
|
configurations = [project.configurations.shadow]
|
||||||
exclude("META-INF")
|
|
||||||
relocate 'ca.spottedleaf.concurrentutil', 'ca.spottedleaf.moonrise.libs.ca.spottedleaf.concurrentutil'
|
relocate 'ca.spottedleaf.concurrentutil', 'ca.spottedleaf.moonrise.libs.ca.spottedleaf.concurrentutil'
|
||||||
relocate 'org.yaml.snakeyaml', 'ca.spottedleaf.moonrise.libs.org.yaml.snakeyaml'
|
relocate 'org.yaml.snakeyaml', 'ca.spottedleaf.moonrise.libs.org.yaml.snakeyaml'
|
||||||
}
|
}
|
||||||
@@ -108,3 +115,4 @@ publishing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Aw2At.setup(getProject(), tasks.remapJar)
|
||||||
|
|||||||
@@ -10,3 +10,5 @@ loader_version=0.15.11
|
|||||||
mod_version=1.0.0
|
mod_version=1.0.0
|
||||||
maven_group=ca.spottedleaf.moonrise
|
maven_group=ca.spottedleaf.moonrise
|
||||||
archives_base_name=moonrise
|
archives_base_name=moonrise
|
||||||
|
|
||||||
|
loom.platform=neoforge
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
maven {
|
maven {
|
||||||
name = 'Fabric'
|
name = 'Fabric'
|
||||||
url = 'https://maven.fabricmc.net/'
|
url = 'https://maven.fabricmc.net/'
|
||||||
}
|
}
|
||||||
mavenCentral()
|
maven {
|
||||||
gradlePluginPortal()
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases/'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = 'jmp'
|
||||||
|
url = 'https://repo.jpenilla.xyz/snapshots'
|
||||||
|
mavenContent { snapshotsOnly() }
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = 'architectury'
|
||||||
|
url = 'https://maven.architectury.dev/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,11 +77,15 @@ public class TickThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TickThread(final Runnable run, final String name) {
|
public TickThread(final Runnable run, final String name) {
|
||||||
this(run, name, ID_GENERATOR.incrementAndGet());
|
this(run, name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TickThread(final Runnable run, final String name, final int id) {
|
public TickThread(final Runnable run, final String name, final ThreadGroup group) {
|
||||||
super(run, name);
|
this(run, name, group, ID_GENERATOR.incrementAndGet());
|
||||||
|
}
|
||||||
|
|
||||||
|
private TickThread(final Runnable run, final String name, final ThreadGroup group, final int id) {
|
||||||
|
super(group, run, name);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.concurrent.Executor;
|
|||||||
@Mixin(ChunkMap.DistanceManager.class)
|
@Mixin(ChunkMap.DistanceManager.class)
|
||||||
public abstract class ChunkMap$DistanceManagerMixin extends net.minecraft.server.level.DistanceManager implements ChunkSystemDistanceManager {
|
public abstract class ChunkMap$DistanceManagerMixin extends net.minecraft.server.level.DistanceManager implements ChunkSystemDistanceManager {
|
||||||
|
|
||||||
@Shadow
|
@Shadow(aliases = "this$0")
|
||||||
@Final
|
@Final
|
||||||
ChunkMap field_17443;
|
ChunkMap field_17443;
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public abstract class DistanceManagerMixin implements ChunkSystemDistanceManager
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public <T> void addRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier) {
|
public <T> void addRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier, boolean forceTicks) { // TODO: Neo added param
|
||||||
this.getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier);
|
this.getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ public abstract class DistanceManagerMixin implements ChunkSystemDistanceManager
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
public <T> void removeRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier) {
|
public <T> void removeRegionTicket(final TicketType<T> type, final ChunkPos pos, final int radius, final T identifier, boolean forceTicks) { // TODO: Neo added param
|
||||||
this.getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier);
|
this.getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - radius, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,11 @@ public abstract class LevelMixin implements ChunkSystemLevel, ChunkSystemEntityG
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z",
|
method = {
|
||||||
|
"setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z",
|
||||||
|
// NeoForge splits logic from the original method into this one
|
||||||
|
"markAndNotifyBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/chunk/LevelChunk;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;II)V"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/level/FullChunkStatus;isOrAfter(Lnet/minecraft/server/level/FullChunkStatus;)Z"
|
target = "Lnet/minecraft/server/level/FullChunkStatus;isOrAfter(Lnet/minecraft/server/level/FullChunkStatus;)Z"
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop<T
|
|||||||
* @reason Make server thread an instance of TickThread for thread checks
|
* @reason Make server thread an instance of TickThread for thread checks
|
||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
|
/* TODO NeoForge adds ThreadGroup
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "spin",
|
method = "spin",
|
||||||
at = @At(
|
at = @At(
|
||||||
@@ -188,6 +189,22 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop<T
|
|||||||
private static Thread createTickThread(final Runnable target, final String name) {
|
private static Thread createTickThread(final Runnable target, final String name) {
|
||||||
return new TickThread(target, name);
|
return new TickThread(target, name);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @reason Make server thread an instance of TickThread for thread checks
|
||||||
|
* @author Spottedleaf
|
||||||
|
*/
|
||||||
|
@Redirect(
|
||||||
|
method = "spin",
|
||||||
|
at = @At(
|
||||||
|
value = "NEW",
|
||||||
|
target = "(Ljava/lang/ThreadGroup;Ljava/lang/Runnable;Ljava/lang/String;)Ljava/lang/Thread;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
private static Thread createTickThreadNeo(final ThreadGroup group, final Runnable task, final String name) {
|
||||||
|
return new TickThread(task, name, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
|||||||
@Mixin(ServerChunkCache.MainThreadExecutor.class)
|
@Mixin(ServerChunkCache.MainThreadExecutor.class)
|
||||||
public abstract class ServerChunkCache$MainThreadExecutorMixin extends BlockableEventLoop<Runnable> {
|
public abstract class ServerChunkCache$MainThreadExecutorMixin extends BlockableEventLoop<Runnable> {
|
||||||
|
|
||||||
@Shadow
|
@Shadow(aliases = "this$0")
|
||||||
@Final
|
@Final
|
||||||
ServerChunkCache field_18810;
|
ServerChunkCache field_18810;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskSchedule
|
|||||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator;
|
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ThreadedTicketLevelPropagator;
|
||||||
import ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer;
|
import ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||||
|
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||||
|
import net.minecraft.CrashReportCategory;
|
||||||
|
import net.minecraft.CrashReportDetail;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
@@ -379,7 +383,10 @@ public abstract class ServerLevelMixin extends Level implements ChunkSystemServe
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "method_31420",
|
method = {
|
||||||
|
"method_31420",
|
||||||
|
"*(Lnet/minecraft/world/TickRateManager;Lnet/minecraft/util/profiling/ProfilerFiller;Lnet/minecraft/world/entity/Entity;)V"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/level/DistanceManager;inEntityTickingRange(J)Z"
|
target = "Lnet/minecraft/server/level/DistanceManager;inEntityTickingRange(J)Z"
|
||||||
@@ -447,7 +454,7 @@ public abstract class ServerLevelMixin extends Level implements ChunkSystemServe
|
|||||||
method = "addPlayer",
|
method = "addPlayer",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;addNewEntity(Lnet/minecraft/world/level/entity/EntityAccess;)Z"
|
target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;*(Lnet/minecraft/world/level/entity/EntityAccess;)Z"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private <T extends EntityAccess> boolean redirectAddPlayerEntity(final PersistentEntitySectionManager<T> instance, final T entity) {
|
private <T extends EntityAccess> boolean redirectAddPlayerEntity(final PersistentEntitySectionManager<T> instance, final T entity) {
|
||||||
@@ -685,15 +692,15 @@ public abstract class ServerLevelMixin extends Level implements ChunkSystemServe
|
|||||||
* @reason Redirect to new entity manager
|
* @reason Redirect to new entity manager
|
||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@WrapOperation(
|
||||||
method = "method_54438",
|
method = "fillReportDetails",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;count()I"
|
target = "Lnet/minecraft/CrashReportCategory;setDetail(Ljava/lang/String;Lnet/minecraft/CrashReportDetail;)Lnet/minecraft/CrashReportCategory;"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private int redirectCrashCount(final PersistentEntitySectionManager<Entity> instance) {
|
private CrashReportCategory redirectCrashCount(final CrashReportCategory instance, final String s, final CrashReportDetail<String> string, final Operation<CrashReportCategory> original) {
|
||||||
return this.moonrise$getEntityLookup().getEntityCount();
|
return original.call(instance, s, (CrashReportDetail<String>) () -> String.valueOf(this.moonrise$getEntityLookup().getEntityCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.spongepowered.asm.mixin.Overwrite;
|
|||||||
@Mixin(FarmBlock.class)
|
@Mixin(FarmBlock.class)
|
||||||
public abstract class FarmBlockMixin {
|
public abstract class FarmBlockMixin {
|
||||||
|
|
||||||
|
// TODO: NeoForge - APIs this method calls require a BlockPos, so is there much advantage to not using betweenClosed anymore?
|
||||||
/**
|
/**
|
||||||
* @reason Avoid usage of betweenClosed, this can become very hot when
|
* @reason Avoid usage of betweenClosed, this can become very hot when
|
||||||
* there are significant numbers of farm blocks in the world
|
* there are significant numbers of farm blocks in the world
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ public abstract class AcquirePoiMixin {
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "method_46885",
|
method = {
|
||||||
|
"method_46885",
|
||||||
|
"*(ZLorg/apache/commons/lang3/mutable/MutableLong;Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;Ljava/util/function/Predicate;Lnet/minecraft/world/entity/ai/behavior/declarative/MemoryAccessor;Ljava/util/Optional;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/PathfinderMob;J)Z"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;findAllClosestFirstWithType(Ljava/util/function/Predicate;Ljava/util/function/Predicate;Lnet/minecraft/core/BlockPos;ILnet/minecraft/world/entity/ai/village/poi/PoiManager$Occupancy;)Ljava/util/stream/Stream;",
|
target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;findAllClosestFirstWithType(Ljava/util/function/Predicate;Ljava/util/function/Predicate;Lnet/minecraft/core/BlockPos;ILnet/minecraft/world/entity/ai/village/poi/PoiManager$Occupancy;)Ljava/util/stream/Stream;",
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ public interface ServerAddressResolverMixin {
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "method_36903",
|
method = {
|
||||||
|
"method_36903",
|
||||||
|
"*(Lnet/minecraft/client/multiplayer/resolver/ServerAddress;)Ljava/util/Optional;"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"
|
target = "Ljava/net/InetAddress;getByName(Ljava/lang/String;)Ljava/net/InetAddress;"
|
||||||
|
|||||||
31
src/main/resources/META-INF/neoforge.mods.toml
Normal file
31
src/main/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
modLoader = "javafml"
|
||||||
|
loaderVersion = "[1,)"
|
||||||
|
license = "GPLv3"
|
||||||
|
issueTrackerURL = "https://github.com/Tuinity/Moonrise"
|
||||||
|
showAsResourcePack = false
|
||||||
|
|
||||||
|
[[mods]]
|
||||||
|
modId = "moonrise"
|
||||||
|
version = "${version}"
|
||||||
|
displayName = "Moonrise"
|
||||||
|
displayURL = "https://github.com/Tuinity/Moonrise"
|
||||||
|
authors = "Spottedleaf"
|
||||||
|
description = "Moonrise NeoForge"
|
||||||
|
displayTest = "IGNORE_ALL_VERSION"
|
||||||
|
|
||||||
|
[[dependencies.moonrise]]
|
||||||
|
modId = "neoforge"
|
||||||
|
type = "required"
|
||||||
|
versionRange = "[21.0,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "BOTH"
|
||||||
|
|
||||||
|
[[dependencies.moonrise]]
|
||||||
|
modId = "minecraft"
|
||||||
|
type = "required"
|
||||||
|
versionRange = "[1.21,1.22)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "BOTH"
|
||||||
|
|
||||||
|
[[mixins]]
|
||||||
|
config = "moonrise.mixins.json"
|
||||||
Reference in New Issue
Block a user