feat: 假人多次生成bug修复及附魔机制修改

This commit is contained in:
Disy authored and zly2006 committed 2024-07-11 12:14:02 +08:00
1 parent 68c8482eee
commit a3e3fb361f
7 files changed
+55 -25

No files matched your search

@@ -27,6 +27,12 @@ public class SLSCarpetSettings {
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
public static boolean canUseSitCommand = false;
@Rule(categories = {CARPET_ID}, strict = false, options = {"#none"})
public static String botPrefix = "#none";
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
public static boolean creativeObeyEnchantmentRule = false;
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
public static boolean fakePlayersNotOccupiedSleepQuota = false;
@@ -6,6 +6,7 @@ import carpet.helpers.EntityPlayerActionPack;
import carpet.patches.EntityPlayerMPFake;
import carpet.patches.FakeClientConnection;
import carpet.utils.Messenger;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import com.github.zly2006.carpetslsaddition.ServerMain;
import com.github.zly2006.carpetslsaddition.util.access.PlayerAccess;
import com.mojang.authlib.GameProfile;
@@ -197,7 +198,7 @@ public class BotCommand {
private static boolean cantSpawn(CommandContext<ServerCommandSource> context)
{
String playerName = StringArgumentType.getString(context, "player");
String playerName = getBotPrefix() + StringArgumentType.getString(context, "player");
MinecraftServer server = context.getSource().getServer();
PlayerManager manager = server.getPlayerManager();
@@ -231,6 +232,10 @@ public class BotCommand {
return false;
}
private static String getBotPrefix() {
return SLSCarpetSettings.botPrefix.equals("#none") ? "" : SLSCarpetSettings.botPrefix;
}
private static int kill(CommandContext<ServerCommandSource> context)
{
if (cantReMove(context)) return 0;
@@ -274,7 +279,7 @@ public class BotCommand {
source.getWorld().getRegistryKey()
);
String playerName = "bot_" + StringArgumentType.getString(context, "player");
String playerName = getBotPrefix() + StringArgumentType.getString(context, "player");
if (playerName.length() > maxNameLength(source.getServer()))
{
Messenger.m(source, "rb Player name: " + playerName + " is too long");
@@ -0,0 +1,29 @@
package com.github.zly2006.carpetslsaddition.mixin.screen;
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.AnvilScreenHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(AnvilScreenHandler.class)
public class MixinAnvilScreenHandler {
@Redirect(
method = "updateResult",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerEntity;getAbilities()Lnet/minecraft/entity/player/PlayerAbilities;"
)
)
private PlayerAbilities updateResult(PlayerEntity instance) {
if (SLSCarpetSettings.creativeObeyEnchantmentRule) {
var ability = new PlayerAbilities();
ability.creativeMode = false;
return ability;
}
return instance.getAbilities();
}
}
@@ -30,11 +30,8 @@ public class ShulkerBoxItemUtil {
if (itemStack.getItem() instanceof BlockItem &&
((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) {
NbtComponent tag = itemStack.getComponents().get(DataComponentTypes.BLOCK_ENTITY_DATA);
if (tag != null) {
if (tag.contains("Items")) {
NbtList tagList = tag.getNbt().getList("Items", 10);
return tagList.size() <= 0;
}
if (tag != null && tag.contains("Items")) {
return tag.getNbt().getList("Items", 10).isEmpty();
}
return true;
} else {