Skip to content

Commit

Permalink
Merge branch 'ver/1.20.1' into ver/1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Sep 14, 2023
2 parents b836a80 + 87428f1 commit d42a0b1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ public class ModuleEntryPoint {
""".indent(1))
.getString(DEFAULT_EXPRESSION, DEFAULT_EXPRESSION);

public static final boolean disableLoggingShutdownHook = new ConfigSystem.ConfigAccessor()
.key("fixes.disableLoggingShutdownHook")
.comment("""
Whether to disable the shutdown hook of log4j2 on dedicated servers.
Enabling this also makes the JVM exit when the dedicated server is considered fully shut down.
This option have no effect on client-side.
We has historically been doing this, and this config option allows you to disable this behavior.
""".indent(1))
.incompatibleMod("textile_backup", "*")
.getBoolean(true, false);

public static final int defaultParallelism;

private static int tryEvaluateExpression(String expression) {
Expand Down
21 changes: 21 additions & 0 deletions c2me-base/src/main/java/com/ishland/c2me/base/TheMixinPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ishland.c2me.base;

import com.ishland.c2me.base.common.ModuleMixinPlugin;

/**
* Used internally for c2me-base, do not subclass.
*/
public final class TheMixinPlugin extends ModuleMixinPlugin {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (!super.shouldApplyMixin(targetClassName, mixinClassName)) {
return false;
}

if (mixinClassName.startsWith("com.ishland.c2me.base.mixin.util.log4j2shutdownhookisnomore."))
return ModuleEntryPoint.disableLoggingShutdownHook;

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ private String getSystemPropertyOverride() {

private void disableConfigWithReason(String reason) {
incompatibilityReason.append("\n ").append(reason);
LOGGER.info("Disabling config {}: {}", this.key, reason);
this.incompatibilityDetected = true;
if (!Boolean.getBoolean("com.ishland.c2me.base.config.ignoreIncompatibility")) {
LOGGER.info("Disabling config {}: {}", this.key, reason);
this.incompatibilityDetected = true;
} else {
LOGGER.info("Compatibility issues ignored by system property: {}: {}", this.key, reason);
}
}

private void generateDefaultEntry(Object def, Object incompatibleDef) {
Expand Down
2 changes: 1 addition & 1 deletion c2me-base/src/main/resources/c2me-base.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"parent": "c2me.mixins.json",
"required": true,
"package": "com.ishland.c2me.base.mixin",
"plugin": "com.ishland.c2me.base.common.ModuleMixinPlugin",
"plugin": "com.ishland.c2me.base.TheMixinPlugin",
"mixins": [
"access.IAquiferSamplerFluidLevel",
"access.IAtomicSimpleRandomDeriver",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.ishland.c2me.base.common.util.FilteringIterable;
import com.ishland.c2me.notickvd.common.IChunkTicketManager;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import it.unimi.dsi.fastutil.longs.LongSet;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ChunkTicketManager;
Expand All @@ -11,7 +13,6 @@
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.Redirect;

@Mixin(ServerChunkManager.class)
public class MixinServerChunkManager {
Expand All @@ -25,11 +26,11 @@ public class MixinServerChunkManager {
// }


@Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;iterateEntities()Ljava/lang/Iterable;"))
private Iterable<Entity> redirectIterateEntities(ServerWorld serverWorld) {
@WrapOperation(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;iterateEntities()Ljava/lang/Iterable;"))
private Iterable<Entity> redirectIterateEntities(ServerWorld serverWorld, Operation<Iterable<Entity>> op) {
final LongSet noTickOnlyChunks = ((IChunkTicketManager) this.ticketManager).getNoTickOnlyChunks();
if (noTickOnlyChunks == null) return serverWorld.iterateEntities();
return new FilteringIterable<>(serverWorld.iterateEntities(), entity -> !noTickOnlyChunks.contains(entity.getChunkPos().toLong()));
if (noTickOnlyChunks == null) return op.call(serverWorld);
return new FilteringIterable<>(op.call(serverWorld), entity -> !noTickOnlyChunks.contains(entity.getChunkPos().toLong()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public final class ModuleEntryPoint {
Whether to use the fast reduced allocation chunk serializer
(may cause incompatibility with other mods)
""")
.incompatibleMod("architectury", "*")
.getBoolean(false, false);

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private static void setAccessibleObjectToPublic(AccessibleObject obj) {
private static Field getReflectedField(ClassField clssfild) {
try {
return clssfild.clss.getField(clssfild.fild());
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (NoSuchFieldException ignored) {

}
return null;
}
Expand Down Expand Up @@ -80,4 +80,4 @@ private static Class getNestedClass(Class upperClass, String nestedClassName) {
}

private record ClassField(Class clss, String fild) {};
}
}

0 comments on commit d42a0b1

Please sign in to comment.