This commit is contained in:
zly2006 committed 2024-07-13 16:24:08 +08:00
1 parent 6df7dac28e
commit 42eefdbef2
16 files changed
+165 -482

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
# Carpet SLS Addition # Carpet SLS Addition
This is an extension of the [Carpet Mod](https://github.com/gnembon/fabric-carpet). This is an extension of the [Carpet Mod](https://github.com/gnembon/fabric-carpet) that is made for [StarLight Server](https://www.starlight.cool/).
## StarLight Server # Rules
[Homepage](https://www.starlight.cool/) [English](rules.md) | [简体中文](rules_zh.md)
+76
View File
@@ -0,0 +1,76 @@
# Bot
SLS addition provides a bot system, with better permission control and more features.
## Permission
You can use LuckPerms or any other permission plugin to control the permission of the bot.
The permission node of the bot is `slsaddition.command.bot`.
## Carpet rules
### botPrefix (carpet rule)
The name prefix of bots. set to `#none` to disable.
### botMaxOnlineTime (carpet rule)
The maximum online time of a bot in seconds. set to 0 to disable.
The bot will be kicked if it exceeds this time.
# Rules
### obtainableReinforcedDeepSlate
If a falling anvil lands on 9 stacks of deepslate block, it will turn into a reinforced deepslate block.
### creativeNoInfinitePickup
In creative mode, you can't pick up items if your inventory is full.
### noBatSpawning
Bats will not spawn naturally.
### canUseHatCommand
Players can use the `/hat` command to wear a block on their head.
### canUseSitCommand
Players can use the `/sit` command to sit on a stair block.
### creativeObeyEnchantmentRule
In creative mode, the enchantment rule will be obeyed as in survival mode.
### fakePlayersNotOccupiedSleepQuota
Fake players will not occupy the sleep quota, and sleeping fake players will not skip the night.
### emptyShulkerBoxStack
Shulker boxes will be empty when stacked.
### playerSit
Players can sit by pressing sneaking key three times.
### endermanCanPickUpMushroom
Endermen can pick up mushrooms. Default is true.
### oldRedstoneConnectionLogic
Use the old redstone connection logic, the redstone can connect to redstone wries on trapdoors.
### optimizedOnDragonRespawn
Optimized the dragon respawn logic, for endstone farms. Ported from Carpet AMS Addition.
### elytraCraftable
Elytra in crafting recipes won't be consumed. This allows players to craft extra elytras.
### spectatorCannotUseLeash
When player becomes spectator, the leash will be detached.
+76
View File
@@ -0,0 +1,76 @@
# Bot 系统
SLS 添加提供了一个机器人系统,具有更好的权限控制和更多功能。
## 权限
您可以使用 LuckPerms 或任何其他权限插件来控制机器人的权限。
机器人的权限节点为 `slsaddition.command.bot`。
## Carpet 规则
### botPrefix (carpet 规则)
机器人名称的前缀。设置为 `#none` 以禁用。
### botMaxOnlineTime (carpet 规则)
机器人的最大在线时间(秒)。设置为 0 以禁用。
如果超过此时间,机器人将被踢出。
# 规则
### obtainableReinforcedDeepSlate
如果一个下落的铁砧落在 9 堆深板岩块上,它将变成强化深板岩块。
### creativeNoInfinitePickup
在创造模式下,如果你的物品栏已满,你不能捡起物品。
### noBatSpawning
蝙蝠不会自然生成。
### canUseHatCommand
玩家可以使用 `/hat` 命令将一个方块戴在头上。
### canUseSitCommand
玩家可以使用 `/sit` 命令坐在楼梯方块上。
### creativeObeyEnchantmentRule
在创造模式下,将遵守生存模式下的附魔规则。
### fakePlayersNotOccupiedSleepQuota
假玩家不会占用睡眠配额,睡眠的假玩家不会跳过夜晚。
### emptyShulkerBoxStack
潜影盒堆叠时将为空。
### playerSit
玩家可以通过三次按下潜行键来坐下。
### endermanCanPickUpMushroom
末影人可以捡起蘑菇。默认为 true。
### oldRedstoneConnectionLogic
使用旧的红石连接逻辑,红石可以连接到活板门上的红石线。
### optimizedOnDragonRespawn
优化了龙的重生逻辑,用于末地石农场。从 Carpet AMS Addition 移植。
### elytraCraftable
在制作配方中,鞘翅不会被消耗。这允许玩家制作额外的鞘翅。
### spectatorCannotUseLeash
当玩家成为旁观者时,拴绳将断开。
@@ -12,10 +12,6 @@ public class SLSCarpetSettings {
@Rule(categories = {SLSA, RuleCategory.SURVIVAL}) @Rule(categories = {SLSA, RuleCategory.SURVIVAL})
public static boolean obtainableReinforcedDeepSlate = false; public static boolean obtainableReinforcedDeepSlate = false;
/** Carpet SLS Addition original **/
@Rule(categories = {SLSA, RuleCategory.OPTIMIZATION})
public static int skipTicksForJoblessVillager = 0;
/** Carpet SLS Addition original **/ /** Carpet SLS Addition original **/
@Rule(categories = {SLSA, RuleCategory.CREATIVE}) @Rule(categories = {SLSA, RuleCategory.CREATIVE})
public static boolean creativeNoInfinitePickup = false; public static boolean creativeNoInfinitePickup = false;
@@ -48,10 +44,6 @@ public class SLSCarpetSettings {
@Rule(categories = {SLSA, RuleCategory.FEATURE}) @Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean fakePlayersNotOccupiedSleepQuota = false; public static boolean fakePlayersNotOccupiedSleepQuota = false;
/** Carpet SLS Addition original **/
@Rule(categories = {SLSA, RuleCategory.CREATIVE})
public static int maxUpdateQueueSize = -1;
/** From Plusls Carpet Addition **/ /** From Plusls Carpet Addition **/
@Rule(categories = {SLSA, RuleCategory.FEATURE, NEED_CLIENT}) @Rule(categories = {SLSA, RuleCategory.FEATURE, NEED_CLIENT})
public static boolean emptyShulkerBoxStack = false; public static boolean emptyShulkerBoxStack = false;
@@ -72,10 +64,6 @@ public class SLSCarpetSettings {
@Rule(categories = {SLSA, FROM_AMS, RuleCategory.OPTIMIZATION}) @Rule(categories = {SLSA, FROM_AMS, RuleCategory.OPTIMIZATION})
public static boolean optimizedOnDragonRespawn = false; public static boolean optimizedOnDragonRespawn = false;
/** Carpet SLS Addition original **/
@Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean printStackTraceOnVillagerSpawn = false;
/** Carpet SLS Addition original **/ /** Carpet SLS Addition original **/
@Rule(categories = {SLSA, RuleCategory.FEATURE}) @Rule(categories = {SLSA, RuleCategory.FEATURE})
public static boolean elytraCraftable = false; public static boolean elytraCraftable = false;
@@ -5,11 +5,9 @@ import carpet.CarpetServer;
import com.github.zly2006.carpetslsaddition.command.BotCommand; import com.github.zly2006.carpetslsaddition.command.BotCommand;
import com.github.zly2006.carpetslsaddition.command.HatCommand; import com.github.zly2006.carpetslsaddition.command.HatCommand;
import com.github.zly2006.carpetslsaddition.command.SitCommand; import com.github.zly2006.carpetslsaddition.command.SitCommand;
import com.github.zly2006.carpetslsaddition.util.access.SettingsManagerAccessor;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
@@ -22,7 +20,7 @@ import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.io.InputStreamReader;
import java.util.Map; import java.util.Map;
public class ServerMain implements ModInitializer, CarpetExtension { public class ServerMain implements ModInitializer, CarpetExtension {
@@ -44,40 +42,35 @@ public class ServerMain implements ModInitializer, CarpetExtension {
CarpetServer.manageExtension(this); CarpetServer.manageExtension(this);
} }
@Override
public void onGameStarted() {
CarpetServer.settingsManager.parseSettingsClass(SLSCarpetSettings.class);
}
@Override @Override
public void onServerLoaded(MinecraftServer server) { public void onServerLoaded(MinecraftServer server) {
ServerMain.server = server; ServerMain.server = server;
CarpetServer.settingsManager.parseSettingsClass(SLSCarpetSettings.class);
((SettingsManagerAccessor) CarpetServer.settingsManager).carpet_SLS_Addition$loadSettings();
} }
@Override @Override
public Map<String, String> canHasTranslations(String lang) { public Map<String, String> canHasTranslations(String lang) {
Map<String, String> translation = Maps.newHashMap(); Map<String, String> translation = Maps.newHashMap();
String jsonFile;
try { try {
try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/%s.json".formatted(lang))) { try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/%s.json".formatted(lang))) {
assert stream != null; assert stream != null;
jsonFile = new String(stream.readAllBytes(), StandardCharsets.UTF_8); return GSON.fromJson(new InputStreamReader(stream), Map.class);
} }
} catch (IOException | NullPointerException ignored) { } catch (IOException | NullPointerException ignored) {
try { try {
try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/%s.json".formatted("en_us"))) { try (InputStream stream = ServerMain.class.getResourceAsStream("/assets/slsaddition/lang/en_us.json")) {
assert stream != null; assert stream != null;
jsonFile = new String(stream.readAllBytes(), StandardCharsets.UTF_8); return GSON.fromJson(new InputStreamReader(stream), Map.class);
} }
} catch (IOException | NullPointerException e) { } catch (IOException | NullPointerException e) {
return translation; return translation;
} }
} }
GSON.fromJson(jsonFile, JsonObject.class).entrySet().stream()
.filter(entry -> entry.getValue().isJsonPrimitive())
.map(entry -> Map.entry(entry.getKey(), entry.getValue().getAsString()))
.forEach(entry -> {
translation.put(entry.getKey(), entry.getValue());
});
return translation;
} }
@Override @Override
@@ -1,183 +0,0 @@
package com.github.zly2006.carpetslsaddition.block;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.block.NeighborUpdater;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
public class RewriteChainRestrictedNeighborUpdater implements NeighborUpdater {
private static final Logger LOGGER = LoggerFactory.getLogger("Minecraft");
private final World world;
private final int maxChainDepth;
private final ArrayDeque<Entry> queue = new ArrayDeque<>();
private final List<Entry> pending = new ArrayList<>();
private int depth = 0;
// rewrite part
private boolean needUpdate = true;
public RewriteChainRestrictedNeighborUpdater(World world, int maxChainDepth) {
this.world = world;
this.maxChainDepth = maxChainDepth;
}
public void replaceWithStateForNeighborUpdate(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) {
this.enqueue(pos, new StateReplacementEntry(direction, neighborState, pos.toImmutable(), neighborPos.toImmutable(), flags, maxUpdateDepth));
}
public void updateNeighbor(BlockPos pos, Block sourceBlock, BlockPos sourcePos) {
this.enqueue(pos, new SimpleEntry(pos, sourceBlock, sourcePos.toImmutable()));
}
public void updateNeighbor(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
this.enqueue(pos, new StatefulEntry(state, pos.toImmutable(), sourceBlock, sourcePos.toImmutable(), notify));
}
public void updateNeighbors(BlockPos pos, Block sourceBlock, @Nullable Direction except) {
this.enqueue(pos, new SixWayEntry(pos.toImmutable(), sourceBlock, except));
}
private void enqueue(BlockPos pos, Entry entry) {
if (!needUpdate) {
return;
}
int maxSize = SLSCarpetSettings.maxUpdateQueueSize;
if (maxSize > 0) {
needUpdate = this.pending.size() + this.queue.size() + 1 <= maxSize;
}
boolean notEmpty = this.depth > 0;
boolean isFull = this.maxChainDepth >= 0 && this.depth >= this.maxChainDepth;
++this.depth;
if (!isFull) {
if (notEmpty) {
this.pending.add(entry);
} else {
this.queue.push(entry);
}
}
else if (this.depth - 1 == this.maxChainDepth) {
LOGGER.error("Too many chained neighbor updates. Skipping the rest. First skipped position: " + pos.toShortString());
}
if (!notEmpty) {
this.runQueuedUpdates();
}
}
private void runQueuedUpdates() {
try {
while(!this.queue.isEmpty() || !this.pending.isEmpty()) {
if (SLSCarpetSettings.maxUpdateQueueSize == 0) {
break;
}
for(int i = this.pending.size() - 1; i >= 0; --i) {
this.queue.push(this.pending.get(i));
}
this.pending.clear();
Entry entry = this.queue.peek();
assert entry != null;
while(this.pending.isEmpty()) {
if (needUpdate) {
if (!entry.update(this.world)) {
this.queue.pop();
break;
}
}
else {
entry.update(this.world);
throw new OutOfMemoryError("Create by Carpet-SLS-Addition");
}
}
}
}
catch (OutOfMemoryError e) {
if (e.getMessage().endsWith("Carpet-SLS-Addition")) {
LOGGER.error("The update queue exceeded the maximum allowed allocation of heap space set by SLS Addition!", e);
}
else {
throw e;
}
}
finally {
this.queue.clear();
this.pending.clear();
this.depth = 0;
needUpdate = true;
}
}
private interface Entry {
boolean update(World world);
}
private record StateReplacementEntry(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int updateFlags, int updateLimit) implements Entry {
public boolean update(World world) {
NeighborUpdater.replaceWithStateForNeighborUpdate(world, this.direction, this.neighborState, this.pos, this.neighborPos, this.updateFlags, this.updateLimit);
return false;
}
}
record SimpleEntry(BlockPos pos, Block sourceBlock, BlockPos sourcePos) implements Entry {
public boolean update(World world) {
BlockState blockState = world.getBlockState(this.pos);
NeighborUpdater.tryNeighborUpdate(world, blockState, this.pos, this.sourceBlock, this.sourcePos, false);
return false;
}
}
record StatefulEntry(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean movedByPiston) implements Entry {
public boolean update(World world) {
NeighborUpdater.tryNeighborUpdate(world, this.state, this.pos, this.sourceBlock, this.sourcePos, this.movedByPiston);
return false;
}
}
static final class SixWayEntry implements Entry {
private final BlockPos pos;
private final Block sourceBlock;
@Nullable
private final Direction except;
private int currentDirectionIndex = 0;
SixWayEntry(BlockPos pos, Block sourceBlock, @Nullable Direction except) {
this.pos = pos;
this.sourceBlock = sourceBlock;
this.except = except;
if (NeighborUpdater.UPDATE_ORDER[this.currentDirectionIndex] == except) {
++this.currentDirectionIndex;
}
}
public boolean update(World world) {
BlockPos blockPos = this.pos.offset(NeighborUpdater.UPDATE_ORDER[this.currentDirectionIndex++]);
BlockState blockState = world.getBlockState(blockPos);
blockState.neighborUpdate(world, blockPos, this.sourceBlock, this.pos, false);
if (this.currentDirectionIndex < NeighborUpdater.UPDATE_ORDER.length && NeighborUpdater.UPDATE_ORDER[this.currentDirectionIndex] == this.except) {
++this.currentDirectionIndex;
}
return this.currentDirectionIndex < NeighborUpdater.UPDATE_ORDER.length;
}
}
}
@@ -1,43 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.carpet;
import carpet.api.settings.CarpetRule;
import carpet.api.settings.SettingsManager;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import com.github.zly2006.carpetslsaddition.ServerMain;
import com.github.zly2006.carpetslsaddition.util.NeighborUpdaterChanger;
import com.github.zly2006.carpetslsaddition.util.access.SettingsManagerAccessor;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ServerWorld;
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.CallbackInfoReturnable;
@Mixin(value = SettingsManager.class, remap = false)
public abstract class MixinSettingsManager implements SettingsManagerAccessor {
@Shadow protected abstract void loadConfigurationFromConf();
@Override
public void carpet_SLS_Addition$loadSettings() {
this.loadConfigurationFromConf();
}
@Inject(method = "setRule", at = @At(value = "INVOKE", target = "Lcarpet/utils/Messenger;m(Lnet/minecraft/server/command/ServerCommandSource;[Ljava/lang/Object;)V", shift = At.Shift.BEFORE), remap = true)
private void injectSetRule(ServerCommandSource source, CarpetRule<?> rule, String newValue, CallbackInfoReturnable<Integer> cir) {
if ("maxUpdateQueueSize".equals(rule.name())) {
MinecraftServer server = ServerMain.server;
if (server != null)
{
server.execute(() -> {
for (ServerWorld world : server.getWorlds())
{
((NeighborUpdaterChanger)world).useRewriteChainNeighborUpdater(SLSCarpetSettings.maxUpdateQueueSize > -1);
}
});
}
}
}
}
@@ -1,9 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.elytra;
import net.minecraft.recipe.Recipe;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Recipe.class)
public interface MixinRecipe {
}
@@ -1,89 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.entity;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import com.github.zly2006.carpetslsaddition.ServerMain;
import net.minecraft.entity.EntityData;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.passive.MerchantEntity;
import net.minecraft.entity.passive.VillagerEntity;
import net.minecraft.village.VillagerData;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(VillagerEntity.class)
public abstract class MixinVillagerEntity extends MerchantEntity {
@Shadow public abstract VillagerData getVillagerData();
@Shadow protected abstract void decayGossip();
@Unique
int tickCount = 0;
public MixinVillagerEntity(EntityType<? extends MerchantEntity> entityType, World world) {
super(entityType, world);
}
@Inject(at = @At("HEAD"), method = "initialize")
private void injectInitialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CallbackInfoReturnable<EntityData> cir) {
if (SLSCarpetSettings.printStackTraceOnVillagerSpawn) {
var logBuilder = new StringBuilder("\n=== Villager Spawn Report ===\n");
logBuilder.append("// Generated by Carpet SLS Addition\n");
try {
logBuilder.append("- Spawn Reason: ").append(spawnReason.toString()).append("\n");
logBuilder.append("- World: ").append(this.getWorld().getRegistryKey().getValue().toString()).append("\n");
logBuilder.append("- Position: ").append("(x=%.2f, y=%.2f, z=%.2f)".formatted(this.getX(), this.getY(), this.getZ())).append("\n");
logBuilder.append("- Stack Trance: ");
var exception = new Exception();
for (var element : exception.getStackTrace()) {
logBuilder.append("\n ").append(element.toString());
}
}
catch (Exception e) {
logBuilder.append("// Sorry but we fail to generate the villager spawn report.\n");
logBuilder.append("- Error Stack Trance: ");
for (var element : e.getStackTrace()) {
logBuilder.append("\n ").append(element.toString());
}
}
logBuilder.append("\n ================================");
ServerMain.LOGGER.warn(logBuilder.toString());
}
}
@Inject(at = @At("HEAD"), method = "tick", cancellable = true)
private void onTick(CallbackInfo ci) {
if (SLSCarpetSettings.skipTicksForJoblessVillager != 0) {
VillagerProfession profession = this.getVillagerData().getProfession();
if (profession != VillagerProfession.NONE && profession != VillagerProfession.NITWIT) {
tickCount = 0;
return;
}
if (tickCount > 0) {
tickCount--;
}
else {
tickCount = SLSCarpetSettings.skipTicksForJoblessVillager;
ci.cancel();
if (this.getHeadRollingTimeLeft() > 0) {
this.setHeadRollingTimeLeft(this.getHeadRollingTimeLeft() - 1);
}
this.decayGossip();
}
}
}
}
@@ -1,24 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.server;
import com.github.zly2006.carpetslsaddition.util.access.ServerAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.server.dedicated.ServerPropertiesLoader;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Environment(EnvType.SERVER)
@Mixin(MinecraftDedicatedServer.class)
public class MixinMinecraftDedicatedServer implements ServerAccessor {
@Shadow
@Final
private ServerPropertiesLoader propertiesLoader;
@Override
public ServerPropertiesLoader getPropertiesLoader() {
return propertiesLoader;
}
}
@@ -1,34 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.server;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.function.BooleanSupplier;
@Mixin(MinecraftServer.class)
public abstract class MixinMinecraftServer {
@Redirect(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tick(Ljava/util/function/BooleanSupplier;)V"))
private void redirectTicking(MinecraftServer instance, BooleanSupplier shouldKeepTicking) {
if (SLSCarpetSettings.maxUpdateQueueSize != -1) {
try {
instance.tick(shouldKeepTicking);
}
catch (Throwable throwable) {
if (throwable instanceof OutOfMemoryError oom) {
if (!oom.getMessage().startsWith("Create by Carpet-SLS-Addition")) {
throw throwable;
}
}
else {
throw throwable;
}
}
}
else {
instance.tick(shouldKeepTicking);
}
}
}
@@ -1,43 +0,0 @@
package com.github.zly2006.carpetslsaddition.mixin.world;
import com.github.zly2006.carpetslsaddition.ServerMain;
import com.github.zly2006.carpetslsaddition.block.RewriteChainRestrictedNeighborUpdater;
import com.github.zly2006.carpetslsaddition.util.NeighborUpdaterChanger;
import com.github.zly2006.carpetslsaddition.util.access.ServerAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.world.World;
import net.minecraft.world.block.NeighborUpdater;
import org.spongepowered.asm.mixin.*;
@Mixin(World.class)
public abstract class MixinWorld implements NeighborUpdaterChanger {
@Mutable
@Shadow
@Final
protected NeighborUpdater neighborUpdater;
@Unique
private NeighborUpdater previousUpdater = null;
@Override
public void useRewriteChainNeighborUpdater(boolean use) {
if (use) {
this.previousUpdater = this.neighborUpdater;
int maxDepth;
if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER) {
maxDepth = ((ServerAccessor) ServerMain.server).getPropertiesLoader().getPropertiesHandler().maxChainedNeighborUpdates;
}
else {
maxDepth = 1000000;
}
this.neighborUpdater = new RewriteChainRestrictedNeighborUpdater((World)(Object)this, maxDepth);
}
else {
this.neighborUpdater = previousUpdater;
}
}
}
@@ -1,5 +0,0 @@
package com.github.zly2006.carpetslsaddition.util;
public interface NeighborUpdaterChanger {
void useRewriteChainNeighborUpdater(boolean use);
}
@@ -1,7 +0,0 @@
package com.github.zly2006.carpetslsaddition.util.access;
import net.minecraft.server.dedicated.ServerPropertiesLoader;
public interface ServerAccessor {
ServerPropertiesLoader getPropertiesLoader();
}
@@ -1,5 +0,0 @@
package com.github.zly2006.carpetslsaddition.util.access;
public interface SettingsManagerAccessor {
void carpet_SLS_Addition$loadSettings();
}
+1 -9
View File
@@ -3,20 +3,15 @@
"minVersion": "0.8", "minVersion": "0.8",
"package": "com.github.zly2006.carpetslsaddition.mixin", "package": "com.github.zly2006.carpetslsaddition.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"server": [
"server.MixinMinecraftDedicatedServer"
],
"client": [ "client": [
], ],
"mixins": [ "mixins": [
"block.BlockPatternTestTransformInvoker", "block.BlockPatternTestTransformInvoker",
"block.MixinRedstoneWireBlock", "block.MixinRedstoneWireBlock",
"carpet.MixinEntityPlayerMPFake", "carpet.MixinEntityPlayerMPFake",
"carpet.MixinSettingsManager",
"datapack.MixinVanillaResourcePackProvider", "datapack.MixinVanillaResourcePackProvider",
"elytra.MixinElytraItem", "elytra.MixinElytraItem",
"elytra.MixinItem", "elytra.MixinItem",
"elytra.MixinRecipe",
"entity.MixinArmorStandEntity", "entity.MixinArmorStandEntity",
"entity.MixinBoatEntity", "entity.MixinBoatEntity",
"entity.MixinEnderDragonFight", "entity.MixinEnderDragonFight",
@@ -25,18 +20,15 @@
"entity.MixinMobEntity", "entity.MixinMobEntity",
"entity.MixinPlayerEntity", "entity.MixinPlayerEntity",
"entity.MixinServerPlayerEntity", "entity.MixinServerPlayerEntity",
"entity.MixinVillagerEntity",
"player.MixinPlayerInventory", "player.MixinPlayerInventory",
"screen.MixinAnvilScreenHandler", "screen.MixinAnvilScreenHandler",
"server.MixinMinecraftServer",
"shulker.MixinItemStack", "shulker.MixinItemStack",
"shulker.MixinPlayerInventory", "shulker.MixinPlayerInventory",
"shulker.MixinScreenHandler", "shulker.MixinScreenHandler",
"shulker.MixinServerPlayNetworkHandler", "shulker.MixinServerPlayNetworkHandler",
"shulker.MixinSlot", "shulker.MixinSlot",
"world.MixinSleepManager", "world.MixinSleepManager",
"world.MixinSpawnHelper", "world.MixinSpawnHelper"
"world.MixinWorld"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1