feat: update java21

This commit is contained in:
Disy authored and zly2006 committed 2024-07-11 12:14:02 +08:00
1 parent 15764d67bc
commit cb3443d37f
15 files changed
+123 -34

No files matched your search

@@ -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) {}
}
}
@@ -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);
}
}
}
@@ -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();
}
}
}