diff --git a/README.md b/README.md index 2ca3314e..6dc99d24 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A Bukkit server implementation utilizing Mixin. | Minecraft | Forge | Status | Build | |:---------:|:-------:| :---: |:------------------------------------------------------------------------------------------------------------------------------------------------------:| -| 1.19.x | 42.0.0 | ACTIVE | [![1.19 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) | +| 1.19.x | 43.1.3 | ACTIVE | [![1.19 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) | | 1.18.x | 40.1.59 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) | | 1.17.x | 37.1.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.17/1.0.2) | [![1.17 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-17?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-17) | | 1.16.x | 36.2.26 | ACTIVE | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) | diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftServerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftServerMixin.java index d138f498..f90d3f09 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftServerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftServerMixin.java @@ -13,13 +13,11 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.CommandEvent; -import net.minecraftforge.event.level.LevelEvent; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.craftbukkit.v.CraftServer; -import org.bukkit.craftbukkit.v.CraftWorld; import org.bukkit.craftbukkit.v.command.CraftBlockCommandSender; import org.bukkit.craftbukkit.v.command.CraftCommandMap; import org.bukkit.craftbukkit.v.entity.CraftEntity; @@ -110,12 +108,6 @@ public abstract class CraftServerMixin implements CraftServerBridge { return null; } - @Inject(method = "unloadWorld(Lorg/bukkit/World;Z)Z", remap = false, require = 1, at = @At(value = "INVOKE", ordinal = 1, target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;")) - private void arclight$unloadForge(World world, boolean save, CallbackInfoReturnable cir) { - MinecraftForge.EVENT_BUS.post(new LevelEvent.Unload(((CraftWorld) world).getHandle())); - this.console.markWorldsDirty(); - } - @ModifyVariable(method = "dispatchCommand", remap = false, index = 2, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lorg/spigotmc/AsyncCatcher;catchOp(Ljava/lang/String;)V")) private String arclight$forgeCommandEvent(String commandLine, CommandSender sender) { CommandSourceStack commandSource; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/EntityArgumentMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/EntityArgumentMixin.java index 437395f9..a1447de0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/EntityArgumentMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/EntityArgumentMixin.java @@ -2,18 +2,14 @@ package io.izzel.arclight.common.mixin.core.commands.arguments; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import io.izzel.arclight.common.bridge.core.command.CommandSourceBridge; import io.izzel.arclight.common.bridge.core.command.arguments.EntityArgumentBridge; import io.izzel.arclight.common.bridge.core.command.arguments.EntitySelectorParserBridge; -import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.commands.arguments.EntityArgument; import net.minecraft.commands.arguments.selector.EntitySelector; import net.minecraft.commands.arguments.selector.EntitySelectorParser; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import static net.minecraft.commands.arguments.EntityArgument.ERROR_NOT_SINGLE_ENTITY; import static net.minecraft.commands.arguments.EntityArgument.ERROR_NOT_SINGLE_PLAYER; @@ -51,9 +47,4 @@ public class EntityArgumentMixin implements EntityArgumentBridge { return entityselector; } } - - @Redirect(method = "listSuggestions", at = @At(value = "INVOKE", target = "Lnet/minecraft/commands/SharedSuggestionProvider;hasPermission(I)Z")) - private boolean arclight$canUseSelector(SharedSuggestionProvider instance, int i) { - return ((CommandSourceBridge) instance).bridge$hasPermission(i, "minecraft.command.selector"); - } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/selector/EntitySelectorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/selector/EntitySelectorMixin.java deleted file mode 100644 index be20d068..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/arguments/selector/EntitySelectorMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.izzel.arclight.common.mixin.core.commands.arguments.selector; - -import io.izzel.arclight.common.bridge.core.command.CommandSourceBridge; -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.arguments.selector.EntitySelector; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(EntitySelector.class) -public class EntitySelectorMixin { - - @Redirect(method = "checkPermissions", at = @At(value = "INVOKE", target = "Lnet/minecraft/commands/CommandSourceStack;hasPermission(I)Z")) - private boolean arclight$stringPermission(CommandSourceStack commandSource, int level) { - return ((CommandSourceBridge) commandSource).bridge$hasPermission(level, "minecraft.command.selector"); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerLoginNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerLoginNetHandlerMixin.java index 68a2c860..08a861d5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerLoginNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerLoginNetHandlerMixin.java @@ -11,7 +11,6 @@ import net.minecraft.core.UUIDUtil; import net.minecraft.network.Connection; import net.minecraft.network.PacketSendListener; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ThrowingComponent; import net.minecraft.network.protocol.game.ClientboundDisconnectPacket; import net.minecraft.network.protocol.login.ClientboundGameProfilePacket; import net.minecraft.network.protocol.login.ClientboundHelloPacket; @@ -67,7 +66,7 @@ public abstract class ServerLoginNetHandlerMixin implements ServerLoginNetHandle @Shadow public abstract String getUserName(); @Shadow private ServerPlayer delayedAcceptPlayer; @Shadow @Nullable private ProfilePublicKey.Data profilePublicKeyData; - @Shadow @Nullable private static ProfilePublicKey validatePublicKey(@org.jetbrains.annotations.Nullable ProfilePublicKey.Data p_240244_, UUID p_240245_, SignatureValidator p_240246_, boolean p_240247_) throws ThrowingComponent { return null; } + @Shadow @Nullable private static ProfilePublicKey validatePublicKey(@org.jetbrains.annotations.Nullable ProfilePublicKey.Data p_240244_, UUID p_240245_, SignatureValidator p_240246_, boolean p_240247_) throws ProfilePublicKey.ValidationException { return null; } // @formatter:on public String hostname; @@ -107,8 +106,8 @@ public abstract class ServerLoginNetHandlerMixin implements ServerLoginNetHandle SignatureValidator signaturevalidator = this.server.getServiceSignatureValidator(); profilePublicKey = validatePublicKey(this.profilePublicKeyData, this.gameProfile.getId(), signaturevalidator, this.server.enforceSecureProfile()); - } catch (ThrowingComponent e) { - LOGGER.error(e.getMessage(), e.getCause()); + } catch (ProfilePublicKey.ValidationException e) { + LOGGER.error("Failed to validate profile key: {}", e.getMessage()); if (!this.connection.isMemoryConnection()) { this.disconnect(e.getComponent()); return; @@ -217,7 +216,7 @@ public abstract class ServerLoginNetHandlerMixin implements ServerLoginNetHandle try { PrivateKey privatekey = this.server.getKeyPair().getPrivate(); if (this.profilePublicKeyData != null) { - ProfilePublicKey profilepublickey = ProfilePublicKey.createTrusted(this.profilePublicKeyData); + ProfilePublicKey profilepublickey = new ProfilePublicKey(this.profilePublicKeyData); if (!packetIn.isChallengeSignatureValid(this.nonce, profilepublickey)) { throw new IllegalStateException("Protocol error"); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java index a7affa1a..fc818cc5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java @@ -1,6 +1,7 @@ package io.izzel.arclight.common.mixin.core.network; import com.mojang.brigadier.ParseResults; +import com.mojang.datafixers.util.Pair; import io.izzel.arclight.common.bridge.core.entity.EntityBridge; import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.core.inventory.container.ContainerBridge; @@ -54,6 +55,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.animal.Bucketable; +import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.ChatVisiblity; import net.minecraft.world.entity.projectile.AbstractArrow; @@ -140,6 +142,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.nio.charset.StandardCharsets; import java.time.Instant; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -148,6 +151,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.function.UnaryOperator; import java.util.logging.Level; +import java.util.stream.Collectors; @Mixin(ServerGamePacketListenerImpl.class) public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerBridge { @@ -973,6 +977,9 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB private ChatDecorator arclight$asyncChatPreview() { return (player, component) -> ForgeHooks.getServerChatPreviewDecorator().decorate(player, component) .thenApplyAsync(forgeComponent -> { + if (player == null) { + return forgeComponent; + } AsyncPlayerChatPreviewEvent event = new AsyncPlayerChatPreviewEvent(true, ((ServerPlayerEntityBridge) player).bridge$getBukkitEntity(), CraftChatMessage.fromComponent(forgeComponent), new LazyPlayerSet(server)); String originalFormat = event.getFormat(), originalMessage = event.getMessage(); this.cserver.getPluginManager().callEvent(event); @@ -1189,7 +1196,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB float f6 = Mth.sin(-f1 * 0.017453292f); float f7 = f4 * f5; float f8 = f3 * f5; - double d4 = (this.player.gameMode.getGameModeForPlayer() == GameType.CREATIVE) ? 5.0 : 4.5; + double d4 = this.player.getReachDistance(); Vec3 vec3d2 = vec3d.add(f7 * d4, f6 * d4, f8 * d4); HitResult result = this.player.level.clip(new ClipContext(vec3d, vec3d2, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); if (result == null || result.getType() != HitResult.Type.BLOCK) { @@ -1273,6 +1280,10 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { // Refresh the current entity metadata send(new ClientboundSetEntityDataPacket(entity.getId(), entity.getEntityData(), true)); + if (entity instanceof Allay) { + send(new ClientboundSetEquipmentPacket(entity.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) entity).getItemBySlot(slot).copy())).collect(Collectors.toList()))); + player.containerMenu.sendAllDataToRemote(); + } } if (event.isCancelled()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java index f69756c6..7d9a9a71 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java @@ -478,6 +478,18 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop VERSION_HASH = Map.of( - "1.19.1", "8399e1211e95faa421c1507b322dbeae86d604df" + "1.19.2", "f69c284232d7c7580bd89a5a4931c3581eae1378" ); private static final Map MAPPING_HASH = Map.of( - "1.19.1", "3565648cdd47ae15738fb804a95a659137d7cfd3" + "1.19.2", "ed5e6e8334ad67f5af0150beed0f3d156d74bd57" ); public static List modInstall(Consumer logger) throws Throwable {