Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ val aw2at = Aw2AtTask.configureDefault(
)

sourceSets.create("lithium")
sourceSets.create("architectury")

neoForge {
neoFormVersion = libs.versions.neoform.get()
validateAccessTransformers = true
accessTransformers.files.setFrom(aw2at.flatMap { t -> t.outputFile })
addModdingDependenciesTo(sourceSets.getByName("lithium"))
addModdingDependenciesTo(sourceSets.getByName("architectury"))
}

dependencies {
Expand All @@ -36,6 +38,7 @@ dependencies {
compileOnly(libs.clothConfig.neoforge)

"lithiumCompileOnly"("maven.modrinth:lithium:${rootProject.property("neo_lithium_version")}")
"architecturyCompileOnly"("maven.modrinth:architectury-api:${rootProject.property("neo_architectury_version")}")
compileOnly(sourceSets.getByName("lithium").output)
}

Expand Down
3 changes: 3 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ dependencies {

runtimeOnly(rootProject.sourceSets.main.get().output)
runtimeOnly(rootProject.sourceSets.getByName("lithium").output)
runtimeOnly(rootProject.sourceSets.getByName("architectury").output)
shadow(project(":"))
shadow(rootProject.sourceSets.getByName("lithium").output)
shadow(rootProject.sourceSets.getByName("architectury").output)
compileOnly(project(":"))

libs(libs.concurrentutil) { isTransitive = false }
Expand Down Expand Up @@ -111,6 +113,7 @@ loom {
sourceSet("main")
sourceSet("main", project.rootProject)
sourceSet("lithium", project.rootProject)
sourceSet("architectury", project.rootProject)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ca.spottedleaf.moonrise.common.util.BaseChunkSystemHooks;
import ca.spottedleaf.moonrise.common.PlatformHooks;
import ca.spottedleaf.moonrise.common.util.ConfigHolder;
import ca.spottedleaf.moonrise.compat.architectury.ArchitecturyHooks;
import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType;
import com.mojang.datafixers.DSL;
import com.mojang.datafixers.DataFixer;
Expand Down Expand Up @@ -43,6 +44,7 @@
public final class FabricHooks extends BaseChunkSystemHooks implements PlatformHooks {

private static final boolean HAS_FABRIC_LIFECYCLE_EVENTS = FabricLoader.getInstance().isModLoaded("fabric-lifecycle-events-v1");
public static final boolean HAS_ARCHITECTURY = FabricLoader.getInstance().isModLoaded("architectury");

private static final Logger LOGGER = LogUtils.getLogger();

Expand Down Expand Up @@ -112,7 +114,9 @@ public void chunkUnloadFromWorld(final LevelChunk chunk) {

@Override
public void chunkSyncSave(final ServerLevel world, final ChunkAccess chunk, final SerializableChunkData data) {

if (HAS_ARCHITECTURY) {
ArchitecturyHooks.onSaveEvent(chunk, world, data);
}
}

@Override
Expand Down Expand Up @@ -174,6 +178,9 @@ public void entityMove(final Entity entity, final long oldSection, final long ne

@Override
public boolean screenEntity(final ServerLevel world, final Entity entity, final boolean fromDisk, final boolean event) {
if (HAS_ARCHITECTURY) {
return ArchitecturyHooks.onEntityAdd(entity, world);
}
return true;
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ junit_version=5.11.3
# version ids from modrinth
fabric_lithium_version=iMuOZwcu
neo_lithium_version=LGakFQ7r
neo_architectury_version=baQ6rP1K
3 changes: 3 additions & 0 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ neoForge {
sourceSet(sourceSets.main.get())
sourceSet(rootProject.sourceSets.main.get())
sourceSet(rootProject.sourceSets.getByName("lithium"))
sourceSet(rootProject.sourceSets.getByName("architectury"))
}
}
runs {
Expand All @@ -44,8 +45,10 @@ val gui = rootProject.property("enable_gui").toString() == "true"
dependencies {
runtimeOnly(rootProject.sourceSets.main.get().output)
runtimeOnly(rootProject.sourceSets.getByName("lithium").output)
runtimeOnly(rootProject.sourceSets.getByName("architectury").output)
shadow(project(":"))
shadow(rootProject.sourceSets.getByName("lithium").output)
shadow(rootProject.sourceSets.getByName("architectury").output)
compileOnly(project(":"))

libs(libs.concurrentutil) { isTransitive = false }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.spottedleaf.moonrise.neoforge.mixin.chunk_system;

import net.minecraft.world.level.entity.EntityAccess;
import net.minecraft.world.level.entity.PersistentEntitySectionManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PersistentEntitySectionManager.class)
abstract class NeoForgePersistentEntitySectionManagerMixin<T extends EntityAccess> {
@Inject(
method = "addNewEntityWithoutEvent",
at = @At("HEAD")
)
private void addNewEntityWithoutEvent(T entity, CallbackInfoReturnable<Boolean> cir) {
throw new UnsupportedOperationException();
}

@Inject(
method = "addEntityWithoutEvent",
at = @At("HEAD")
)
private void addEntityWithoutEvent(T entity, boolean worldGenSpawned, CallbackInfoReturnable<Boolean> cir) {
throw new UnsupportedOperationException();
}
}
1 change: 1 addition & 0 deletions neoforge/src/main/resources/moonrise-neoforge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"package": "ca.spottedleaf.moonrise.neoforge.mixin",
"mixins": [
"chunk_system.NeoForgeMinecraftServerMixin",
"chunk_system.NeoForgePersistentEntitySectionManagerMixin",
"chunk_system.NeoForgeServerLevelMixin",
"chunk_system.NeoForgeTicketStorageMixin",
"collisions.EntityMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ca.spottedleaf.moonrise.compat.architectury;

import dev.architectury.event.events.common.ChunkEvent;
import dev.architectury.event.events.common.EntityEvent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.storage.SerializableChunkData;

public final class ArchitecturyHooks {
/**
* Invokes Architectury's ChunkEvent.SAVE_DATA event.
*
* @param chunkAccess The chunk that is saved.
* @param level The level the chunk is in.
* @param data The data.
*/
public static void onSaveEvent(ChunkAccess chunkAccess, ServerLevel level, SerializableChunkData data) {
ChunkEvent.SAVE_DATA.invoker().save(chunkAccess, level, data);
}

/**
* Invokes Architectury's EntityEvent.ADD event.
*
* @param entity The entity that is added.
* @param level The level the entity is in.
* @return Whether the entity should be added.
*/
public static boolean onEntityAdd(Entity entity, ServerLevel level) {
return !EntityEvent.ADD.invoker().add(entity, level).isFalse();
}
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.io.IOException;
import java.io.Writer;
import java.nio.file.Path;
Expand Down Expand Up @@ -480,8 +481,8 @@ public boolean saveChunkIfNeeded(final ChunkHolder chunkHolder, final long time)
* @author Spottedleaf
* @see NewChunkHolder#save(boolean)
*/
@Overwrite
public boolean save(final ChunkAccess chunk) {
@Inject(method = "save", at = @At("HEAD"))
public void save(ChunkAccess chunk, CallbackInfoReturnable<Boolean> cir) {
throw new UnsupportedOperationException();
}

Expand Down
Loading