diff --git a/src/main/java/club/mcams/carpet/AmsServerSettings.java b/src/main/java/club/mcams/carpet/AmsServerSettings.java
index b825f876..68d272f9 100644
--- a/src/main/java/club/mcams/carpet/AmsServerSettings.java
+++ b/src/main/java/club/mcams/carpet/AmsServerSettings.java
@@ -20,13 +20,14 @@
package club.mcams.carpet;
-import club.mcams.carpet.validators.rule.fancyFakePlayerName.FancyFakePlayerNameRuleObserver;
+import club.mcams.carpet.observers.rule.fancyFakePlayerName.FancyFakePlayerNameRuleObserver;
import top.byteeeee.annotationtoolbox.annotation.GameVersion;
//#if MC>=12002
-//$$ import club.mcams.carpet.validators.rule.stackableDiscount.StackableDiscountRuleObserver;
+//$$ import club.mcams.carpet.observers.rule.stackableDiscount.StackableDiscountRuleObserver;
//#endif
-import club.mcams.carpet.validators.rule.largeShulkerBox.LargeShulkerBoxRuleObserver;
+import club.mcams.carpet.observers.rule.largeShulkerBox.LargeShulkerBoxRuleObserver;
+
import club.mcams.carpet.validators.rule.maxPlayerBlockInteractionRange.MaxPlayerBlockInteractionRangeValidator;
import club.mcams.carpet.validators.rule.maxPlayerEntityInteractionRange.MaxPlayerEntityInteractionRangeValidator;
import club.mcams.carpet.validators.rule.blockChunkLoaderTimeController.MaxTimeValidator;
@@ -79,8 +80,12 @@ public class AmsServerSettings {
@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean sharedVillagerDiscounts = false;
- @Rule(categories = {AMS, FEATURE})
- public static boolean fakePeace = false;
+ @Rule(
+ options = {"false", "true", "minecraft:overworld", "minecraft:the_end", "minecraft:the_nether", "minecraft:the_end,minecraft:the_nether"},
+ categories = {AMS, FEATURE},
+ strict = false
+ )
+ public static String fakePeace = "false";
@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean extinguishedCampfire = false;
@@ -228,11 +233,10 @@ public class AmsServerSettings {
public static double maxClientInteractionReachDistance = -1.0D;
@Rule(
- options = {"VANILLA", "minecraft:bedrock", "minecraft:bedrock,minecraft:obsidian"},
- categories = {AMS, FEATURE},
- strict = false
+ options = {"0", "1", "2", "3", "4", "ops", "true", "false"},
+ categories = {AMS, FEATURE, COMMAND}
)
- public static String customMovableBlock = "VANILLA";
+ public static String commandCustomMovableBlock = "false";
@Rule(categories = {AMS, FEATURE})
public static boolean easyMaxLevelBeacon = false;
diff --git a/src/main/java/club/mcams/carpet/commands/RegisterCommands.java b/src/main/java/club/mcams/carpet/commands/RegisterCommands.java
index 94904e4e..7eeb5fc7 100644
--- a/src/main/java/club/mcams/carpet/commands/RegisterCommands.java
+++ b/src/main/java/club/mcams/carpet/commands/RegisterCommands.java
@@ -21,6 +21,7 @@
package club.mcams.carpet.commands;
import club.mcams.carpet.commands.rule.commandCustomCommandPermissionLevel.CustomCommandPermissionLevelRegistry;
+import club.mcams.carpet.commands.rule.commandCustomMovableBlock.CustomMovableBlockRegistry;
import club.mcams.carpet.commands.rule.commandGetPlayerSkull.GetPlayerSkullCommandRegistry;
import club.mcams.carpet.commands.rule.commandGetSaveSize.GetSaveSizeCommandRegistry;
import club.mcams.carpet.commands.rule.commandGetSystemInfo.GetSystemInfoCommandRegistry;
@@ -78,5 +79,12 @@ public static void registerCommands(
CustomCommandPermissionLevelRegistry.register(dispatcher);
GetPlayerSkullCommandRegistry.register(dispatcher);
+
+ CustomMovableBlockRegistry.register(
+ dispatcher
+ //#if MC>=11900
+ //$$ , commandBuildContext
+ //#endif
+ );
}
}
diff --git a/src/main/java/club/mcams/carpet/commands/rule/commandCustomMovableBlock/CustomMovableBlockRegistry.java b/src/main/java/club/mcams/carpet/commands/rule/commandCustomMovableBlock/CustomMovableBlockRegistry.java
new file mode 100644
index 00000000..e08b0011
--- /dev/null
+++ b/src/main/java/club/mcams/carpet/commands/rule/commandCustomMovableBlock/CustomMovableBlockRegistry.java
@@ -0,0 +1,166 @@
+/*
+ * This file is part of the Carpet AMS Addition project, licensed under the
+ * GNU Lesser General Public License v3.0
+ *
+ * Copyright (C) 2024 A Minecraft Server and contributors
+ *
+ * Carpet AMS Addition is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Carpet AMS Addition is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Carpet AMS Addition. If not, see .
+ */
+
+package club.mcams.carpet.commands.rule.commandCustomMovableBlock;
+
+import club.mcams.carpet.AmsServerSettings;
+import club.mcams.carpet.translations.Translator;
+import club.mcams.carpet.utils.CommandHelper;
+import club.mcams.carpet.config.rule.commandCustomMovableBlock.CustomMovableBlockConfig;
+
+import club.mcams.carpet.utils.Messenger;
+import club.mcams.carpet.utils.RegexTools;
+import com.mojang.brigadier.CommandDispatcher;
+
+import net.minecraft.block.BlockState;
+import net.minecraft.command.argument.BlockStateArgumentType;
+import net.minecraft.entity.player.PlayerEntity;
+//#if MC>=11900
+//$$ import net.minecraft.command.CommandRegistryAccess;
+//#endif
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.command.CommandManager;
+import net.minecraft.server.command.ServerCommandSource;
+import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.text.Style;
+import net.minecraft.util.Formatting;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static net.minecraft.server.command.CommandManager.argument;
+import static net.minecraft.server.command.CommandManager.literal;
+
+public class CustomMovableBlockRegistry {
+ private static final Translator translator = new Translator("command.customMovableBlock");
+ private static final String MSG_HEAD = " ";
+ public static final List CUSTOM_MOVABLE_BLOCKS = new ArrayList<>();
+
+ //#if MC<11900
+ public static void register(CommandDispatcher dispatcher) {
+ //#else
+ //$$ public static void register(CommandDispatcher dispatcher, CommandRegistryAccess commandRegistryAccess) {
+ //#endif
+ dispatcher.register(
+ CommandManager.literal("customMovableBlock")
+ .requires(source -> CommandHelper.canUseCommand(source, AmsServerSettings.commandCustomMovableBlock))
+ .then(literal("add")
+ //#if MC<11900
+ .then(argument("block", BlockStateArgumentType.blockState())
+ //#else
+ //$$ .then(argument("block", BlockStateArgumentType.blockState(commandRegistryAccess))
+ //#endif
+ .executes(context -> add(
+ context.getSource().getServer(),
+ context.getSource().getPlayer(),
+ BlockStateArgumentType.getBlockState(context, "block").getBlockState()
+ ))))
+ .then(literal("remove")
+ //#if MC<11900
+ .then(argument("block", BlockStateArgumentType.blockState())
+ //#else
+ //$$ .then(argument("block", BlockStateArgumentType.blockState(commandRegistryAccess))
+ //#endif
+ .executes(context -> remove(
+ context.getSource().getServer(),
+ context.getSource().getPlayer(),
+ BlockStateArgumentType.getBlockState(context, "block").getBlockState())
+ )))
+ .then(literal("removeAll")
+ .executes(context -> removeAll(context.getSource().getServer(), context.getSource().getPlayer())))
+ .then(literal("list")
+ .executes(context -> list(context.getSource().getPlayer())))
+ .then(literal("help")
+ .executes(context -> help(context.getSource().getPlayer())))
+ );
+ }
+
+ private static int add(MinecraftServer server, PlayerEntity player, BlockState blockState) {
+ if (!CUSTOM_MOVABLE_BLOCKS.contains(getBlockName(blockState))) {
+ CUSTOM_MOVABLE_BLOCKS.add(getBlockName(blockState));
+ saveToJson(server);
+ player.sendMessage(Messenger.s(MSG_HEAD + "+ " + getBlockName(blockState)).formatted(Formatting.GREEN), false);
+ } else {
+ player.sendMessage(
+ Messenger.s(
+ MSG_HEAD + getBlockName(blockState) + translator.tr("already_exists").getString()
+ ).formatted(Formatting.YELLOW), false
+ );
+ }
+ return 1;
+ }
+
+ private static int remove(MinecraftServer server, PlayerEntity player, BlockState blockState) {
+ if (CUSTOM_MOVABLE_BLOCKS.contains(getBlockName(blockState))) {
+ CUSTOM_MOVABLE_BLOCKS.remove(getBlockName(blockState));
+ saveToJson(server);
+ player.sendMessage(Messenger.s(MSG_HEAD + "- " + getBlockName(blockState)).formatted(Formatting.RED), false);
+ } else {
+ player.sendMessage(Messenger.s(MSG_HEAD + getBlockName(blockState) + translator.tr("not_found").getString()).formatted(Formatting.RED), false);
+ }
+ return 1;
+ }
+
+ private static int removeAll(MinecraftServer server, PlayerEntity player) {
+ CUSTOM_MOVABLE_BLOCKS.clear();
+ saveToJson(server);
+ player.sendMessage(Messenger.s(MSG_HEAD + translator.tr("removeAll").getString()).formatted(Formatting.RED), false);
+ return 1;
+ }
+
+ private static int list(ServerPlayerEntity player) {
+ player.sendMessage(
+ Messenger.s(
+ translator.tr("list").getString() + "\n-------------------------------").formatted(Formatting.GREEN),
+ false
+ );
+ for (String blockName : CUSTOM_MOVABLE_BLOCKS) {
+ player.sendMessage(Messenger.s(blockName).formatted(Formatting.GREEN), false);
+ }
+ return 1;
+ }
+
+ private static int help(ServerPlayerEntity player) {
+ String setHelpText = translator.tr("help.set").getString();
+ String removeHelpText = translator.tr("help.remove").getString();
+ String removeAllHelpText = translator.tr("help.removeAll").getString();
+ String listHelpText = translator.tr("help.list").getString();
+ player.sendMessage(
+ Messenger.s(
+ "\n" +
+ setHelpText + "\n" +
+ removeHelpText + "\n" +
+ removeAllHelpText + "\n" +
+ listHelpText
+ ).setStyle(Style.EMPTY.withColor(Formatting.GRAY)),
+ false
+ );
+ return 1;
+ }
+
+ private static void saveToJson(MinecraftServer server) {
+ String CONFIG_FILE_PATH = CustomMovableBlockConfig.getPath(server);
+ CustomMovableBlockConfig.saveToJson(CUSTOM_MOVABLE_BLOCKS, CONFIG_FILE_PATH);
+ }
+
+ private static String getBlockName(BlockState blockState) {
+ return RegexTools.getBlockRegisterName(blockState.getBlock().toString());
+ }
+}
diff --git a/src/main/java/club/mcams/carpet/commands/rule/commandGoto/GotoCommandRegistry.java b/src/main/java/club/mcams/carpet/commands/rule/commandGoto/GotoCommandRegistry.java
index d7b99be8..b4a64124 100644
--- a/src/main/java/club/mcams/carpet/commands/rule/commandGoto/GotoCommandRegistry.java
+++ b/src/main/java/club/mcams/carpet/commands/rule/commandGoto/GotoCommandRegistry.java
@@ -24,6 +24,10 @@
import club.mcams.carpet.utils.CommandHelper;
import club.mcams.carpet.utils.compat.DimensionWrapper;
+//#if MC>=12102
+//$$ import java.util.Set;
+//#endif
+
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.argument.BlockPosArgumentType;
@@ -57,7 +61,11 @@ private static int executeTeleport(ServerPlayerEntity player, ServerWorld target
int x = destinationPos.getX();
int y = destinationPos.getY();
int z = destinationPos.getZ();
+ //#if MC>=12102
+ //$$ player.teleport(targetDimension, x, y, z, Set.of(), player.getPitch(1), 1, false);
+ //#else
player.teleport(targetDimension, x, y, z, player.getYaw(1), player.getPitch(1));
+ //#endif
return 1;
}
diff --git a/src/main/java/club/mcams/carpet/config/LoadConfigFromJson.java b/src/main/java/club/mcams/carpet/config/LoadConfigFromJson.java
index e05d42c7..43ca3bb9 100644
--- a/src/main/java/club/mcams/carpet/config/LoadConfigFromJson.java
+++ b/src/main/java/club/mcams/carpet/config/LoadConfigFromJson.java
@@ -22,10 +22,13 @@
import club.mcams.carpet.commands.rule.commandCustomBlockBlastResistance.CustomBlockBlastResistanceCommandRegistry;
import club.mcams.carpet.commands.rule.commandCustomCommandPermissionLevel.CustomCommandPermissionLevelRegistry;
+import club.mcams.carpet.commands.rule.commandCustomMovableBlock.CustomMovableBlockRegistry;
import club.mcams.carpet.commands.rule.commandPlayerLeader.LeaderCommandRegistry;
+import club.mcams.carpet.config.rule.amsUpdateSuppressionCrashFix.ForceModeCommandConfig;
import club.mcams.carpet.config.rule.commandCustomBlockBlastResistance.CustomBlockBlastResistanceConfig;
import club.mcams.carpet.config.rule.commandCustomCommandPermissionLevel.CustomCommandPermissionLevelConfig;
+import club.mcams.carpet.config.rule.commandCustomMovableBlock.CustomMovableBlockConfig;
import club.mcams.carpet.config.rule.commandLeader.LeaderConfig;
import net.minecraft.server.MinecraftServer;
@@ -33,14 +36,17 @@
public class LoadConfigFromJson {
public static void load(MinecraftServer server) {
clearMemory();
+ ForceModeCommandConfig.loadConfigFromJson(server);
CustomBlockBlastResistanceConfig.loadFromJson(CustomBlockBlastResistanceConfig.getPath(server));
LeaderConfig.loadFromJson(LeaderConfig.getPath(server));
CustomCommandPermissionLevelConfig.loadFromJson(CustomCommandPermissionLevelConfig.getPath(server));
+ CustomMovableBlockConfig.loadFromJson(CustomMovableBlockConfig.getPath(server));
}
private static void clearMemory() {
CustomBlockBlastResistanceCommandRegistry.CUSTOM_BLOCK_BLAST_RESISTANCE_MAP.clear();
LeaderCommandRegistry.LEADER_LIST.clear();
CustomCommandPermissionLevelRegistry.COMMAND_PERMISSION_MAP.clear();
+ CustomMovableBlockRegistry.CUSTOM_MOVABLE_BLOCKS.clear();
}
}
diff --git a/src/main/java/club/mcams/carpet/config/rule/commandCustomMovableBlock/CustomMovableBlockConfig.java b/src/main/java/club/mcams/carpet/config/rule/commandCustomMovableBlock/CustomMovableBlockConfig.java
new file mode 100644
index 00000000..704ff12b
--- /dev/null
+++ b/src/main/java/club/mcams/carpet/config/rule/commandCustomMovableBlock/CustomMovableBlockConfig.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the Carpet AMS Addition project, licensed under the
+ * GNU Lesser General Public License v3.0
+ *
+ * Copyright (C) 2024 A Minecraft Server and contributors
+ *
+ * Carpet AMS Addition is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Carpet AMS Addition is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Carpet AMS Addition. If not, see .
+ */
+
+package club.mcams.carpet.config.rule.commandCustomMovableBlock;
+
+import club.mcams.carpet.AmsServer;
+import club.mcams.carpet.commands.rule.commandCustomMovableBlock.CustomMovableBlockRegistry;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.WorldSavePath;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+
+public class CustomMovableBlockConfig {
+ @SuppressWarnings("ReadWriteStringCanBeUsed")
+ public static void loadFromJson(String configFilePath) {
+ Gson gson = new Gson();
+ Path path = Paths.get(configFilePath);
+ CustomMovableBlockRegistry.CUSTOM_MOVABLE_BLOCKS.clear();
+ if (Files.exists(path)) {
+ try {
+ String json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
+ Type type = new TypeToken>() {}.getType();
+ List simplifiedMap = gson.fromJson(json, type);
+ CustomMovableBlockRegistry.CUSTOM_MOVABLE_BLOCKS.addAll(simplifiedMap);
+ } catch (IOException e) {
+ AmsServer.LOGGER.warn("Failed to load config", e);
+ }
+ }
+ }
+
+ @SuppressWarnings("ReadWriteStringCanBeUsed")
+ public static void saveToJson(List customBlockMap, String configFilePath) {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ List simplifiedMap = new ArrayList<>(customBlockMap);
+ String json = gson.toJson(simplifiedMap);
+ try {
+ Path path = Paths.get(configFilePath);
+ Files.createDirectories(path.getParent());
+ Files.write(path, json.getBytes(StandardCharsets.UTF_8));
+ } catch (IOException e) {
+ AmsServer.LOGGER.warn("Failed to save config", e);
+ }
+ }
+
+ public static String getPath(MinecraftServer server) {
+ return server.getSavePath(WorldSavePath.ROOT).resolve("carpetamsaddition/custom_movable_block" + ".json").toString();
+ }
+}
diff --git a/src/main/java/club/mcams/carpet/config/rule/commandLeader/LeaderConfig.java b/src/main/java/club/mcams/carpet/config/rule/commandLeader/LeaderConfig.java
index d5381d54..18a593a2 100644
--- a/src/main/java/club/mcams/carpet/config/rule/commandLeader/LeaderConfig.java
+++ b/src/main/java/club/mcams/carpet/config/rule/commandLeader/LeaderConfig.java
@@ -58,9 +58,9 @@ public static void loadFromJson(String configFilePath) {
}
@SuppressWarnings("ReadWriteStringCanBeUsed")
- public static void saveToJson(Map customBlockMap, String configFilePath) {
+ public static void saveToJson(Map leaderMap, String configFilePath) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
- Map simplifiedMap = new HashMap<>(customBlockMap);
+ Map simplifiedMap = new HashMap<>(leaderMap);
String json = gson.toJson(simplifiedMap);
try {
Path path = Paths.get(configFilePath);
diff --git a/src/main/java/club/mcams/carpet/mixin/rule/customMovableBlock/PistonBlockMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/commandCustomMovableBlock/PistonBlockMixin.java
similarity index 64%
rename from src/main/java/club/mcams/carpet/mixin/rule/customMovableBlock/PistonBlockMixin.java
rename to src/main/java/club/mcams/carpet/mixin/rule/commandCustomMovableBlock/PistonBlockMixin.java
index 7614d810..7e37aac5 100644
--- a/src/main/java/club/mcams/carpet/mixin/rule/customMovableBlock/PistonBlockMixin.java
+++ b/src/main/java/club/mcams/carpet/mixin/rule/commandCustomMovableBlock/PistonBlockMixin.java
@@ -18,13 +18,16 @@
* along with Carpet AMS Addition. If not, see .
*/
-package club.mcams.carpet.mixin.rule.customMovableBlock;
+package club.mcams.carpet.mixin.rule.commandCustomMovableBlock;
import club.mcams.carpet.AmsServerSettings;
+import club.mcams.carpet.commands.rule.commandCustomMovableBlock.CustomMovableBlockRegistry;
import club.mcams.carpet.utils.RegexTools;
import net.minecraft.block.BlockState;
import net.minecraft.block.PistonBlock;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
@@ -34,30 +37,25 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.Objects;
-import java.util.Set;
@Mixin(PistonBlock.class)
public abstract class PistonBlockMixin {
@Inject(method = "isMovable", at = @At("HEAD"), cancellable = true)
private static void MovableBlocks(BlockState state, World world, BlockPos blockPos, Direction direction, boolean canBreak, Direction pistonDir, CallbackInfoReturnable cir) {
- if (!Objects.equals(AmsServerSettings.customMovableBlock, "VANILLA")) {
- Set moreCustomMovableBlock = new HashSet<>(Arrays.asList(AmsServerSettings.customMovableBlock.split(",")));
- String blockName = RegexTools.getBlockRegisterName(state.getBlock().toString()); //Block{minecraft:bedrock} -> minecraft:bedrock
- if (moreCustomMovableBlock.contains(blockName)) {
- //#if MC<11700
- //$$ if (direction == Direction.DOWN && blockPos.getY() == 0) {
- //#else
- if (direction == Direction.DOWN && blockPos.getY() == world.getBottomY()) {
- //#endif
+ if (!Objects.equals(AmsServerSettings.commandCustomMovableBlock, "false") && CustomMovableBlockRegistry.CUSTOM_MOVABLE_BLOCKS.contains(RegexTools.getBlockRegisterName(state.getBlock().toString()))) {
+ BlockEntity blockEntity = world.getBlockEntity(blockPos);
+ //#if MC>=11700
+ boolean isBottomY = blockPos.getY() == world.getBottomY();
+ boolean isTopY = blockPos.getY() == world.getTopY();
+ //#else
+ //$$ boolean isBottomY = blockPos.getY() == 0;
+ //$$ boolean isTopY = blockPos.getY() == world.getHeight() - 1;
+ //#endif
+ if (!(blockEntity instanceof LootableContainerBlockEntity)) {
+ if (direction == Direction.DOWN && isBottomY) {
cir.setReturnValue(false);
- //#if MC<11700
- //$$ } else if (direction == Direction.UP && blockPos.getY() == world.getHeight() - 1) {
- //#else
- } else if (direction == Direction.UP && blockPos.getY() == world.getTopY() - 1) {
- //#endif
+ } else if (direction == Direction.UP && isTopY) {
cir.setReturnValue(false);
} else {
cir.setReturnValue(true);
diff --git a/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/AbstractBlockStateMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/AbstractBlockStateMixin.java
deleted file mode 100644
index 16f3dc2a..00000000
--- a/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/AbstractBlockStateMixin.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This file is part of the Carpet AMS Addition project, licensed under the
- * GNU Lesser General Public License v3.0
- *
- * Copyright (C) 2023 A Minecraft Server and contributors
- *
- * Carpet AMS Addition is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Carpet AMS Addition is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Carpet AMS Addition. If not, see .
- */
-
-package club.mcams.carpet.mixin.rule.fakePeace;
-
-import club.mcams.carpet.AmsServerSettings;
-
-import com.llamalad7.mixinextras.injector.ModifyReturnValue;
-
-import net.minecraft.block.AbstractBlock;
-
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-
-@SuppressWarnings("SimplifiableConditionalExpression")
-@Mixin(AbstractBlock.AbstractBlockState.class)
-public abstract class AbstractBlockStateMixin {
- @ModifyReturnValue(method = "allowsSpawning", at = @At("RETURN"))
- private boolean allowsSpawning(boolean original) {
- return AmsServerSettings.fakePeace ? false : original;
- }
-}
diff --git a/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/ServerWorldMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/ServerWorldMixin.java
new file mode 100644
index 00000000..d9411e28
--- /dev/null
+++ b/src/main/java/club/mcams/carpet/mixin/rule/fakePeace/ServerWorldMixin.java
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the Carpet AMS Addition project, licensed under the
+ * GNU Lesser General Public License v3.0
+ *
+ * Copyright (C) 2023 A Minecraft Server and contributors
+ *
+ * Carpet AMS Addition is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Carpet AMS Addition is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Carpet AMS Addition. If not, see .
+ */
+
+package club.mcams.carpet.mixin.rule.fakePeace;
+
+import club.mcams.carpet.AmsServerSettings;
+import club.mcams.carpet.utils.compat.DimensionWrapper;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.mob.Monster;
+import net.minecraft.server.world.ServerWorld;
+
+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;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+@Mixin(ServerWorld.class)
+public abstract class ServerWorldMixin {
+ @Inject(method = "spawnEntity", at = @At("HEAD"), cancellable = true)
+ private void allowsSpawning(Entity entity, CallbackInfoReturnable cir) {
+ if (!"false".equals(AmsServerSettings.fakePeace) && entity instanceof Monster) {
+ DimensionWrapper worldDimension = DimensionWrapper.of((ServerWorld) (Object) this);
+ Set dimensionCP = new HashSet<>(Arrays.asList(AmsServerSettings.fakePeace.split(",")));
+ if (dimensionCP.contains(worldDimension.getIdentifierString()) || Objects.equals(AmsServerSettings.fakePeace, "true")) {
+ cir.setReturnValue(false);
+ }
+ }
+ }
+}
diff --git a/src/main/resources/amscarpet.mixins.json b/src/main/resources/amscarpet.mixins.json
index 898604fb..fde398bb 100644
--- a/src/main/resources/amscarpet.mixins.json
+++ b/src/main/resources/amscarpet.mixins.json
@@ -32,7 +32,7 @@
"rule.creativeOneHitKill.PlayerEntityMixin",
"rule.creativeShulkerBoxDropsDisabled.ShulkerBoxBlockMixin",
"rule.customBlockUpdateSuppressor.AbstractBlockMixin",
- "rule.customMovableBlock.PistonBlockMixin",
+ "rule.commandCustomMovableBlock.PistonBlockMixin",
"rule.easyCompost.ComposterBlockMixin",
"rule.easyGetPitcherPod.BlockMixin",
"rule.easyMaxLevelBeacon.BeaconBlockEntityMixin",
@@ -45,7 +45,7 @@
"rule.experimentalContentCheckDisabled.FeatureSetMixin",
"rule.experimentalContentCheckDisabled.ToggleableFeatureMixin",
"rule.extinguishedCampfire_campfireSmokeParticleDisabled.CampfireBlockMixin",
- "rule.fakePeace.AbstractBlockStateMixin",
+ "rule.fakePeace.ServerWorldMixin",
"rule.fakePlayerInteractLikeClient.BoatEntityInvoker",
"rule.fakePlayerInteractLikeClient.EntityPlayerActionPackActionTypeMixin",
"rule.fakePlayerNoScoreboardCounter.PlayerEntityMixin",
diff --git a/src/main/resources/assets/carpetamsaddition/lang/en_us.yml b/src/main/resources/assets/carpetamsaddition/lang/en_us.yml
index 74d840f3..8fdf969a 100644
--- a/src/main/resources/assets/carpetamsaddition/lang/en_us.yml
+++ b/src/main/resources/assets/carpetamsaddition/lang/en_us.yml
@@ -84,6 +84,16 @@ carpetamsaddition:
remove: '/customCommandPermissionLevel remove -> Remove a modified command'
removeAll: '/customCommandPermissionLevel removeAll -> Remove all modified commands'
list: '/customCommandPermissionLevel list -> View the list of modified commands'
+ customMovableBlock:
+ already_exists: " is already exists"
+ not_found: " not found"
+ removeAll: "All block have been removed from list"
+ list: "[ Moveable block list ]"
+ help:
+ set: '/customMovableBlock add -> Added a movable block'
+ remove: '/customMovableBlock remove -> Delete a movable block'
+ removeAll: '/customMovableBlock removeAll -> Removes all added movable blocks'
+ list: '/customMovableBlock list -> Check out the list of movable blocks'
logger:
serverRuntime:
@@ -119,7 +129,7 @@ carpetamsaddition:
sharedVillagerDiscounts:
desc: Share villagers discount to all players
fakePeace:
- desc: Simulation fake Peace
+ desc: Simulation fake Peace, You can customize the dimensions in which it works, or you can customize the combination and use "," to separate
extinguishedCampfire:
desc: The campfire is extinguished when the player places it
netherWaterPlacement:
@@ -244,13 +254,10 @@ carpetamsaddition:
extra:
'0': 'The range of values: 0 - 512'
'1': 'Need to disable the tweakBlockReachOverride feature in Tweakeroo'
- customMovableBlock:
- desc: Customize the non-pushable block to make it pushable
+ commandCustomMovableBlock:
+ desc: Customize the non-pushable block to make it pushable (Container blocks are not supported, and if you need to push containers, you can use Carpet's movableBlockEntities rule)
extra:
- '0': 'Command format:'
- '1': '/carpet customMovableBlock minecraft:BlockName'
- '2': 'You can also set multiple blocks simultaneously by separating them with commas:'
- '3': '/carpet customMovableBlock minecraft:BlockName1,minecraft:BlockName2'
+ '0': 'After enabling the rules, use the /customMovableBlock help command to view the usage instructions'
easyMaxLevelBeacon:
desc: Activate full-level beacon with just one base block
commandCustomBlockBlastResistance:
diff --git a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
index 519d619e..3b586b09 100644
--- a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
+++ b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
@@ -84,6 +84,16 @@ carpetamsaddition:
remove: '/customCommandPermissionLevel remove <指令> -> 删除某个被修改的指令'
removeAll: '/customCommandPermissionLevel removeAll -> 删除所有被修改的指令'
list: '/customCommandPermissionLevel list -> 查看被修改的指令列表'
+ customMovableBlock:
+ already_exists: " 已存在"
+ not_found: " 不存在"
+ removeAll: "已删除所有条目"
+ list: "[ 可移动方块列表 ]"
+ help:
+ set: '/customMovableBlock add <方块注册名> -> 增加一个可移动方块'
+ remove: '/customMovableBlock remove <方块注册名> -> 删除一个可移动方块'
+ removeAll: '/customMovableBlock removeAll -> 删除所有添加的可移动方块'
+ list: '/customMovableBlock list -> 查看可移动方块列表'
logger:
serverRuntime:
@@ -122,7 +132,7 @@ carpetamsaddition:
desc: 玩家将僵尸村民治疗为村民后的获得的折扣将共享给所有玩家
fakePeace:
name: 伪和平
- desc: 伪和平
+ desc: 伪和平,你可以自定义其生效的维度,也可以自定义生效的维度组合,使用“,”隔开即可
extinguishedCampfire:
name: 熄灭的篝火
desc: 当玩家放置篝火时,篝火处于熄灭状态
@@ -284,14 +294,11 @@ carpetamsaddition:
extra:
'0': '允许设定的范围:0 - 512'
'1': '需要关闭Tweakeroo的tweakBlockReachOverride功能'
- customMovableBlock:
+ commandCustomMovableBlock:
name: 自定义可移动方块
- desc: 可自定义的让不能被推动的方块变得能被推动
+ desc: 可自定义的让不能被推动的方块变得能被推动(不支持容器方块,如果需要推动容器可以使用Carpet的movableBlockEntities规则)
extra:
- '0': '命令格式:'
- '1': '/carpet customMovableBlock minecraft:BlockName'
- '2': '你也可以同时设置多个方块,使用 "," 隔开即可:'
- '3': '/carpet customMovableBlock minecraft:BlockName1,minecraft:BlockName2'
+ '0': '开启规则后使用/customMovableBlock help命令查看使用说明'
easyMaxLevelBeacon:
name: 简易满级信标
desc: 只需一个底座方块就能激活满级信标