Compare commits
6 Commits
lithium-0.
...
v0.2.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac0c7deb43 | ||
|
|
16c8398d8a | ||
|
|
661ef813bb | ||
|
|
cf1d26a73c | ||
|
|
0cbff02a1c | ||
|
|
ce4ee767fe |
10
build.gradle
10
build.gradle
@@ -18,13 +18,10 @@ def aw2at = Aw2AtTask.configureDefault(
|
||||
sourceSets.main
|
||||
)
|
||||
|
||||
sourceSets.create("lithium")
|
||||
|
||||
neoForge {
|
||||
neoFormVersion = neoform_version
|
||||
validateAccessTransformers = true
|
||||
accessTransformers.files.setFrom(aw2at.flatMap { t -> t.getOutputFile() })
|
||||
addModdingDependenciesTo sourceSets.lithium
|
||||
}
|
||||
|
||||
runConfigCommon {
|
||||
@@ -44,13 +41,6 @@ dependencies {
|
||||
|
||||
// todo: does cloth publish a platform-agnostic jar in mojang mappings?
|
||||
compileOnly "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_version}"
|
||||
|
||||
lithiumCompileOnly("maven.modrinth:lithium:${rootProject.neo_lithium_version}")
|
||||
compileOnly(sourceSets.lithium.output)
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
from(sourceSets.lithium.output)
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -13,7 +13,6 @@ dependencies {
|
||||
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
|
||||
|
||||
runtimeOnly(project(":").sourceSets.main.output)
|
||||
runtimeOnly(project(":").sourceSets.lithium.output)
|
||||
shadow(project(":"))
|
||||
compileOnly(project(":"))
|
||||
|
||||
@@ -86,7 +85,6 @@ loom {
|
||||
main {
|
||||
sourceSet("main")
|
||||
sourceSet("main", project.rootProject)
|
||||
sourceSet("lithium", project.rootProject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,6 @@ public final class FabricHooks extends BaseChunkSystemHooks implements PlatformH
|
||||
return "Moonrise";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(final String modId) {
|
||||
return FabricLoader.getInstance().isModLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightEmission(final BlockState blockState, final BlockGetter world, final BlockPos pos) {
|
||||
return blockState.getLightEmission();
|
||||
|
||||
@@ -8,9 +8,9 @@ org.gradle.configuration-cache=true
|
||||
minecraft_version=1.21.4
|
||||
loader_version=0.16.9
|
||||
supported_minecraft_versions=1.21.4
|
||||
neoforge_version=21.4.59-beta
|
||||
neoforge_version=21.4.33-beta
|
||||
neoform_version=1.21.4-20241203.161809
|
||||
fabric_api_version=0.114.3+1.21.4
|
||||
fabric_api_version=0.110.5+1.21.4
|
||||
snakeyaml_version=2.3
|
||||
concurrentutil_version=0.0.3
|
||||
yamlconfig_version=1.0.2
|
||||
@@ -18,9 +18,9 @@ cloth_version=17.0.144
|
||||
modmenu_version=13.0.0-beta.1
|
||||
junit_version=5.11.3
|
||||
# version ids from modrinth
|
||||
fabric_lithium_version=zVOQw7YU
|
||||
neo_lithium_version=CfXh2ZF6
|
||||
fabric_lithium_version=t1FlWYl9
|
||||
neo_lithium_version=iDqQi66g
|
||||
# Mod Properties
|
||||
mod_version=0.2.0-SNAPSHOT
|
||||
mod_version=0.2.0-beta.9
|
||||
maven_group=ca.spottedleaf.moonrise
|
||||
archives_base_name=moonrise
|
||||
|
||||
@@ -28,7 +28,6 @@ neoForge {
|
||||
moonrise {
|
||||
sourceSet sourceSets.main
|
||||
sourceSet rootProject.sourceSets.main
|
||||
sourceSet rootProject.sourceSets.lithium
|
||||
}
|
||||
}
|
||||
runs {
|
||||
@@ -47,7 +46,6 @@ neoForge {
|
||||
|
||||
dependencies {
|
||||
runtimeOnly(project(":").sourceSets.main.output)
|
||||
runtimeOnly(project(":").sourceSets.lithium.output)
|
||||
shadow(project(":"))
|
||||
compileOnly(project(":"))
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import net.minecraft.world.level.chunk.status.ChunkStatusTasks;
|
||||
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
|
||||
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.LoadingModList;
|
||||
import net.neoforged.neoforge.common.CommonHooks;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.entity.PartEntity;
|
||||
@@ -48,15 +46,6 @@ public final class NeoForgeHooks extends BaseChunkSystemHooks implements Platfor
|
||||
return "Moonrise";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(final String modId) {
|
||||
final ModList modList = ModList.get();
|
||||
if (modList == null) {
|
||||
return LoadingModList.get().getModFileById(modId) != null;
|
||||
}
|
||||
return modList.isLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightEmission(final BlockState blockState, final BlockGetter world, final BlockPos pos) {
|
||||
return blockState.getLightEmission(world, pos);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package ca.spottledleaf.moonrise.compat.lithium;
|
||||
|
||||
import net.caffeinemc.mods.lithium.common.world.chunk.ChunkStatusTracker;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
|
||||
public final class LithiumHooks {
|
||||
private LithiumHooks() {}
|
||||
|
||||
public static void onChunkInaccessible(final ServerLevel serverLevel, final ChunkPos pos) {
|
||||
ChunkStatusTracker.onChunkInaccessible(serverLevel, pos);
|
||||
}
|
||||
|
||||
public static void onChunkAccessible(final ServerLevel serverLevel, final LevelChunk chunk) {
|
||||
ChunkStatusTracker.onChunkAccessible(serverLevel, chunk);
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,6 @@ public interface PlatformHooks extends ChunkSystemHooks {
|
||||
|
||||
public String getBrand();
|
||||
|
||||
public default boolean isModLoaded(final String modId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLightEmission(final BlockState blockState, final BlockGetter world, final BlockPos pos);
|
||||
|
||||
public Predicate<BlockState> maybeHasLightEmission();
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package ca.spottedleaf.moonrise.common.util;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.util.Priority;
|
||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemServerChunkCache;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel;
|
||||
import ca.spottledleaf.moonrise.compat.lithium.LithiumHooks;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.FullChunkStatus;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -21,8 +19,6 @@ import java.util.function.Consumer;
|
||||
|
||||
public abstract class BaseChunkSystemHooks implements ChunkSystemHooks {
|
||||
|
||||
private final boolean hasLithium = ((PlatformHooks)this).isModLoaded("lithium");
|
||||
|
||||
@Override
|
||||
public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run) {
|
||||
scheduleChunkTask(level, chunkX, chunkZ, run, Priority.NORMAL);
|
||||
@@ -105,9 +101,6 @@ public abstract class BaseChunkSystemHooks implements ChunkSystemHooks {
|
||||
((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().add(
|
||||
((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder()
|
||||
);
|
||||
if (this.hasLithium) {
|
||||
LithiumHooks.onChunkAccessible((ServerLevel) chunk.getLevel(), chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,9 +108,6 @@ public abstract class BaseChunkSystemHooks implements ChunkSystemHooks {
|
||||
((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().remove(
|
||||
((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder()
|
||||
);
|
||||
if (this.hasLithium) {
|
||||
LithiumHooks.onChunkInaccessible((ServerLevel) chunk.getLevel(), chunk.getPos());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package ca.spottedleaf.moonrise.common.util;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class EntityUtil {
|
||||
|
||||
private static final ThreadLocal<DecimalFormat> THREE_DECIMAL_PLACES = ThreadLocal.withInitial(() -> {
|
||||
return new DecimalFormat("#,##0.000");
|
||||
});
|
||||
|
||||
private static String formatVec(final Vec3 vec) {
|
||||
final DecimalFormat format = THREE_DECIMAL_PLACES.get();
|
||||
|
||||
return "(" + format.format(vec.x) + "," + format.format(vec.y) + "," + format.format(vec.z) + ")";
|
||||
}
|
||||
|
||||
private static String dumpEntityWithoutReferences(final Entity entity) {
|
||||
if (entity == null) {
|
||||
return "{null}";
|
||||
}
|
||||
|
||||
return "{type=" + entity.getClass().getSimpleName() + ",id=" + entity.getId() + ",uuid=" + entity.getUUID() + ",pos=" + formatVec(entity.position())
|
||||
+ ",mot=" + formatVec(entity.getDeltaMovement()) + ",aabb=" + entity.getBoundingBox() + ",removed=" + entity.getRemovalReason() + ",has_vehicle=" + (entity.getVehicle() != null)
|
||||
+ ",passenger_count=" + entity.getPassengers().size();
|
||||
}
|
||||
|
||||
public static String dumpEntity(final Entity entity) {
|
||||
final List<Entity> passengers = entity.getPassengers();
|
||||
final List<String> passengerStrings = new ArrayList<>(passengers.size());
|
||||
|
||||
for (final Entity passenger : passengers) {
|
||||
passengerStrings.add("(" + dumpEntityWithoutReferences(passenger) + ")");
|
||||
}
|
||||
|
||||
return "{root=[" + dumpEntityWithoutReferences(entity) + "], vehicle=[" + dumpEntityWithoutReferences(entity.getVehicle())
|
||||
+ "], passengers=[" + String.join(",", passengerStrings) + "]";
|
||||
}
|
||||
|
||||
private EntityUtil() {}
|
||||
}
|
||||
@@ -15,21 +15,25 @@ public class TickThread extends Thread {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TickThread.class);
|
||||
|
||||
private static String getThreadContext() {
|
||||
return "thread=" + Thread.currentThread().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static void ensureTickThread(final String reason) {
|
||||
if (!isTickThread()) {
|
||||
LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
LOGGER.error("Thread failed main thread check: " + reason + ", context=" + getThreadContext(), new Throwable());
|
||||
throw new IllegalStateException(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ensureTickThread(final Level world, final BlockPos pos, final String reason) {
|
||||
if (!isTickThreadFor(world, pos)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos;
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -37,8 +41,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Level world, final BlockPos pos, final int blockRadius, final String reason) {
|
||||
if (!isTickThreadFor(world, pos, blockRadius)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + pos + ", block_radius=" + blockRadius;
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -46,8 +50,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Level world, final ChunkPos pos, final String reason) {
|
||||
if (!isTickThreadFor(world, pos)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + pos;
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -55,8 +59,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Level world, final int chunkX, final int chunkZ, final String reason) {
|
||||
if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", chunk_pos=" + new ChunkPos(chunkX, chunkZ);
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -64,8 +68,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Entity entity, final String reason) {
|
||||
if (!isTickThreadFor(entity)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", entity=" + entity;
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", entity=" + EntityUtil.dumpEntity(entity);
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -73,8 +77,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Level world, final AABB aabb, final String reason) {
|
||||
if (!isTickThreadFor(world, aabb)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", aabb=" + aabb;
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
@@ -82,8 +86,8 @@ public class TickThread extends Thread {
|
||||
|
||||
public static void ensureTickThread(final Level world, final double blockX, final double blockZ, final String reason) {
|
||||
if (!isTickThreadFor(world, blockX, blockZ)) {
|
||||
final String ex = "Thread " + Thread.currentThread().getName() + " failed main thread check: " +
|
||||
reason + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
|
||||
final String ex = "Thread failed main thread check: " +
|
||||
reason + ", context=" + getThreadContext() + ", world=" + WorldUtil.getWorldName(world) + ", block_pos=" + new Vec3(blockX, 0.0, blockZ);
|
||||
LOGGER.error(ex, new Throwable());
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package ca.spottedleaf.moonrise.mixin.chunk_system;
|
||||
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(DynamicGameEventListener.class)
|
||||
abstract class DynamicGameEventListenerMixin {
|
||||
@Shadow @Nullable private SectionPos lastSection;
|
||||
|
||||
@Inject(method = "remove", at = @At("RETURN"))
|
||||
private void onRemove(final CallbackInfo ci) {
|
||||
// We need to unset the last section when removed, otherwise if the same instance is re-added at the same position it
|
||||
// will assume there was no change and fail to re-register.
|
||||
// In vanilla, chunks rarely unload and re-load quickly enough to trigger this issue. However, our chunk system has a
|
||||
// quirk where fast chunk reload cycles will often occur on player login (see PR #22).
|
||||
// So we fix this vanilla oversight as our changes cause it to manifest in bugs much more often (see issue #87).
|
||||
this.lastSection = null;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ interface EntityGetterMixin {
|
||||
@Overwrite
|
||||
default boolean isUnobstructed(final Entity entity, final VoxelShape voxel) {
|
||||
if (voxel.isEmpty()) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
final AABB singleAABB = ((CollisionVoxelShape)voxel).moonrise$getSingleAABBRepresentation();
|
||||
|
||||
@@ -55,7 +55,7 @@ abstract class LevelMixin implements LevelAccessor, AutoCloseable {
|
||||
public boolean isUnobstructed(final Entity entity) {
|
||||
final AABB boundingBox = entity.getBoundingBox();
|
||||
if (CollisionUtil.isEmpty(boundingBox)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
final List<Entity> entities = this.getEntities(
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"chunk_system.ChunkStepMixin",
|
||||
"chunk_system.ChunkStorageMixin",
|
||||
"chunk_system.DistanceManagerMixin",
|
||||
"chunk_system.DynamicGameEventListenerMixin",
|
||||
"chunk_system.EntityGetterMixin",
|
||||
"chunk_system.EntityMixin",
|
||||
"chunk_system.EntityTickListMixin",
|
||||
|
||||
Reference in New Issue
Block a user