diff --git a/src/main/java/com/github/zly2006/reden/access/PlayerData.kt b/src/main/java/com/github/zly2006/reden/access/PlayerData.kt index 7dd739ab..5b6b9e2c 100644 --- a/src/main/java/com/github/zly2006/reden/access/PlayerData.kt +++ b/src/main/java/com/github/zly2006/reden/access/PlayerData.kt @@ -4,7 +4,7 @@ import com.github.zly2006.reden.carpet.RedenCarpetSettings import com.github.zly2006.reden.malilib.UNDO_CHEATING_ONLY import com.github.zly2006.reden.mixinhelper.UpdateMonitorHelper import com.github.zly2006.reden.utils.isClient -import net.minecraft.client.MinecraftClient +import com.github.zly2006.reden.utils.isSinglePlayerAndCheating import net.minecraft.command.EntitySelector import net.minecraft.entity.EntityType import net.minecraft.entity.TntEntity @@ -20,12 +20,12 @@ import java.util.* class PlayerData( val player: ServerPlayerEntity, ) { - private infix fun Boolean?.and(other: Boolean?) = this ?: false && other ?: false val canRecord: Boolean - get() = (!isClient && RedenCarpetSettings.allowedUndoSizeInBytes == 0) || - (UNDO_CHEATING_ONLY.booleanValue && MinecraftClient.getInstance()?.let { - (it.server?.isSingleplayer and it.player?.hasPermissionLevel(2)) - } == true) + get() = if (!isClient) { + RedenCarpetSettings.allowedUndoSizeInBytes != 0 + } else if (UNDO_CHEATING_ONLY.booleanValue) { + true + } else isSinglePlayerAndCheating val undo: MutableList = mutableListOf() val redo: MutableList = mutableListOf() var undoUsedBytes: Int = 0 diff --git a/src/main/java/com/github/zly2006/reden/utils/Utils.kt b/src/main/java/com/github/zly2006/reden/utils/Utils.kt index 28563167..81fc15c5 100644 --- a/src/main/java/com/github/zly2006/reden/utils/Utils.kt +++ b/src/main/java/com/github/zly2006/reden/utils/Utils.kt @@ -8,6 +8,7 @@ import net.fabricmc.api.EnvType import net.fabricmc.loader.api.FabricLoader import net.minecraft.block.Block import net.minecraft.block.BlockState +import net.minecraft.client.MinecraftClient import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.entity.player.PlayerEntity import net.minecraft.server.MinecraftServer @@ -86,3 +87,10 @@ object ResourceLoader { fun buttonWidget(x: Int, y: Int, width: Int, height: Int, message: Text, onPress: ButtonWidget.PressAction) = ButtonWidget(x, y, width, height, message, onPress) { it.get() } + +val isSinglePlayerAndCheating: Boolean get() { + infix fun Boolean?.and(other: Boolean?) = this ?: false && other ?: false + return MinecraftClient.getInstance()?.let { + (it.server?.isSingleplayer and it.player?.hasPermissionLevel(2)) + } == true +} diff --git a/src/main/resources/reden.accesswidener b/src/main/resources/reden.accesswidener index 69f3e368..f3da54cb 100644 --- a/src/main/resources/reden.accesswidener +++ b/src/main/resources/reden.accesswidener @@ -31,3 +31,4 @@ accessible method net/minecraft/world/World getDestructionType (Lnet/minecraft/w accessible field net/minecraft/world/chunk/Chunk heightmaps Ljava/util/Map; accessible field net/minecraft/command/EntitySelector PASSTHROUGH_FILTER Lnet/minecraft/util/TypeFilter; accessible field net/minecraft/server/integrated/IntegratedServer localPlayerUuid Ljava/util/UUID; +accessible field net/minecraft/server/world/ServerWorld syncedBlockEventQueue Lit/unimi/dsi/fastutil/objects/ObjectLinkedOpenHashSet;