feat: update java21
This commit is contained in:
1 parent
15764d67bc
commit
cb3443d37f
15 files changed
+123
-34
No files matched your search
@@ -17,15 +17,9 @@ public class SLSCarpetSettings {
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.OPTIMIZATION})
|
||||
public static int skipTicksForJoblessVillager = 0;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.OPTIMIZATION}, options = {"-1", "24", "50"})
|
||||
public static int maxVillagersInABlock = -1;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.CREATIVE})
|
||||
public static boolean creativeNoInfinitePickup = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID})
|
||||
public static boolean autoUrl = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.OPTIMIZATION})
|
||||
public static boolean noBatSpawning = false;
|
||||
|
||||
@@ -38,6 +32,9 @@ public class SLSCarpetSettings {
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
|
||||
public static boolean canUseSitCommand = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
|
||||
public static boolean fakePlayersNotOccupiedSleepQuota = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.CREATIVE})
|
||||
public static int maxUpdateQueueSize = -1;
|
||||
|
||||
@@ -59,6 +56,9 @@ public class SLSCarpetSettings {
|
||||
@Rule(categories = {CARPET_ID, PCA, RuleCategory.FEATURE})
|
||||
public static boolean playerSit = false;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.FEATURE})
|
||||
public static boolean endermanCanPickUpMushroom = true;
|
||||
|
||||
@Rule(categories = {CARPET_ID, RuleCategory.CREATIVE})
|
||||
public static boolean oldRedstoneConnectionLogic = false;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.command.argument.Vec3ArgumentType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.server.Main;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
@@ -42,6 +43,8 @@ import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.minecraft.command.CommandSource.suggestMatching;
|
||||
@@ -49,6 +52,7 @@ import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
|
||||
public class BotCommand {
|
||||
public static final ArrayBlockingQueue<ServerPlayerEntity> playerQueue = new ArrayBlockingQueue<>(128);
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||
{
|
||||
LiteralArgumentBuilder<ServerCommandSource> command = literal("bot")
|
||||
@@ -263,7 +267,7 @@ public class BotCommand {
|
||||
source.getWorld().getRegistryKey()
|
||||
);
|
||||
|
||||
String playerName = "bot_" + StringArgumentType.getString(context, "player");
|
||||
String playerName = StringArgumentType.getString(context, "player");
|
||||
if (playerName.length() > maxNameLength(source.getServer()))
|
||||
{
|
||||
Messenger.m(source, "rb Player name: " + playerName + " is too long");
|
||||
@@ -275,14 +279,25 @@ public class BotCommand {
|
||||
Messenger.m(source, "rb Player " + playerName + " cannot be placed outside of the world");
|
||||
return 0;
|
||||
}
|
||||
ServerPlayerEntity player = EntityPlayerMPFake.createFake(playerName, source.getServer(), pos, facing.y, facing.x, dimType, GameMode.SURVIVAL, false);
|
||||
if (player == null)
|
||||
boolean success = EntityPlayerMPFake.createFake(playerName, source.getServer(), pos, facing.y, facing.x, dimType, GameMode.SURVIVAL, false);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Messenger.m(source, "rb Player " + playerName + " doesn't exist and cannot spawn in online mode. " +
|
||||
"Turn the server offline to spawn non-existing players");
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
ServerPlayerEntity player;
|
||||
try {
|
||||
player = playerQueue.poll(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (player == null) return 1;
|
||||
|
||||
((PlayerAccess) player).setDisplayName(Text.empty().append(Text.literal("[%s] ".formatted(source.getName())).setStyle(Style.EMPTY.withColor(Formatting.AQUA))).append(Text.literal(playerName).setStyle(Style.EMPTY)));
|
||||
ServerMain.server.getPlayerManager().broadcast(Text.empty()
|
||||
.append(Text.literal("假人").setStyle(Style.EMPTY.withColor(Formatting.GREEN)))
|
||||
|
||||
@@ -2,15 +2,20 @@ package com.github.zly2006.carpetslsaddition.mixin.carpet;
|
||||
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||
import com.github.zly2006.carpetslsaddition.command.BotCommand;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.util.Uuids;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Mixin(value = EntityPlayerMPFake.class)
|
||||
public class MixinFakePlayer {
|
||||
@@ -22,4 +27,12 @@ public class MixinFakePlayer {
|
||||
}
|
||||
return instance.findByName(name);
|
||||
}
|
||||
|
||||
@Inject(method = "lambda$createFake$1", at = @At("TAIL"))
|
||||
private static void onAcceptFakePlayer(EntityPlayerMPFake instance, Vec3d pos, double yaw, double pitch, CallbackInfo ci) {
|
||||
try {
|
||||
BotCommand.playerQueue.offer(instance, 500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.github.zly2006.carpetslsaddition.mixin.entity;
|
||||
|
||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.MushroomPlantBlock;
|
||||
import net.minecraft.entity.mob.EndermanEntity;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(EndermanEntity.PickUpBlockGoal.class)
|
||||
public class
|
||||
|
||||
|
||||
|
||||
MixinEndermanGoal {
|
||||
@Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isIn(Lnet/minecraft/registry/tag/TagKey;)Z"))
|
||||
public boolean isHoldable(BlockState blockState, TagKey<Block> tagKey) {
|
||||
if (!SLSCarpetSettings.endermanCanPickUpMushroom) {
|
||||
return blockState.isIn(tagKey) && !(blockState.getBlock() instanceof MushroomPlantBlock);
|
||||
}
|
||||
else {
|
||||
return blockState.isIn(tagKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -30,8 +30,11 @@ public abstract class MixinBeehiveBlockEntity extends BlockEntity {
|
||||
|
||||
@Inject(method = "tickBees", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;remove()V", shift = At.Shift.AFTER))
|
||||
private static void postTickBees(World world, BlockPos pos, BlockState state, List<Object> bees, BlockPos flowerPos, CallbackInfo ci) {
|
||||
if (SLSCarpetSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(Objects.requireNonNull(world.getBlockEntity(pos)))) {
|
||||
ServerMain.LOGGER.debug("update BeehiveBlockEntity: {}", pos);
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity != null) {
|
||||
if (SLSCarpetSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(blockEntity)) {
|
||||
ServerMain.LOGGER.debug("update BeehiveBlockEntity: {}", pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.github.zly2006.carpetslsaddition.mixin.world;
|
||||
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.SleepManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(SleepManager.class)
|
||||
public class MixinSleepManager {
|
||||
|
||||
@Redirect(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;isSpectator()Z"))
|
||||
private boolean isNormalPlayer(ServerPlayerEntity serverPlayerEntity) {
|
||||
if (SLSCarpetSettings.fakePlayersNotOccupiedSleepQuota) {
|
||||
return serverPlayerEntity.isSpectator() || serverPlayerEntity instanceof EntityPlayerMPFake;
|
||||
}
|
||||
else {
|
||||
return serverPlayerEntity.isSpectator();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user