Update to 1.19.2

This commit is contained in:
IzzelAliz 2022-09-02 14:22:09 +08:00
parent 5c4229ff14
commit 0704cbc5fe
11 changed files with 35 additions and 48 deletions

View File

@ -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) |

View File

@ -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<Boolean> 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;

View File

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

View File

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

View File

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

View File

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

View File

@ -478,6 +478,18 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop<T
this.forceTicks = false;
}
// bukkit callbacks
public void addLevel(ServerLevel level) {
this.levels.put(level.dimension(), level);
this.markWorldsDirty();
}
public void removeLevel(ServerLevel level) {
MinecraftForge.EVENT_BUS.post(new LevelEvent.Unload(level));
this.levels.remove(level.dimension());
this.markWorldsDirty();
}
@Inject(method = "tickChildren", at = @At("HEAD"))
public void arclight$runScheduler(BooleanSupplier hasTimeLeft, CallbackInfo ci) {
ArclightConstants.currentTick = (int) (System.currentTimeMillis() / 50);

View File

@ -69,10 +69,10 @@ public abstract class RepairContainerMixin extends ItemCombinerMixin {
j = j + itemstack.getBaseRepairCost() + (itemstack2.isEmpty() ? 0 : itemstack2.getBaseRepairCost());
this.repairItemCountCost = 0;
boolean flag = false;
if (!ForgeHooks.onAnvilChange((AnvilMenu) (Object) this, itemstack, itemstack2, resultSlots, itemName, j, this.player))
return;
if (!itemstack2.isEmpty()) {
if (!ForgeHooks.onAnvilChange((AnvilMenu) (Object) this, itemstack, itemstack2, resultSlots, itemName, j, this.player))
return;
flag = itemstack2.getItem() == Items.ENCHANTED_BOOK && !EnchantedBookItem.getEnchantments(itemstack2).isEmpty();
if (itemstack1.isDamageableItem() && itemstack1.getItem().isValidRepairItem(itemstack, itemstack2)) {
int l2 = Math.min(itemstack1.getDamageValue(), itemstack1.getMaxDamage() / 4);

View File

@ -23,7 +23,6 @@
"commands.CommandSourceStackMixin",
"commands.arguments.EntityArgumentMixin",
"commands.arguments.blocks.BlockStateParserMixin",
"commands.arguments.selector.EntitySelectorMixin",
"commands.arguments.selector.EntitySelectorParserMixin",
"commands.synchronization.ArgumentTypesMixin",
"fluid.FlowingFluidMixin",

View File

@ -13,8 +13,8 @@ allprojects {
ext {
agpVersion = '1.23'
minecraftVersion = '1.19.1'
forgeVersion = '42.0.0'
minecraftVersion = '1.19.2'
forgeVersion = '43.1.3'
apiVersion = '1.3.0'
toolsVersion = '1.3.+'
mixinVersion = '0.8.5'

View File

@ -59,10 +59,10 @@ public class ForgeInstaller {
private static final String SERVER_URL = "https://arclight.mcxk.net/net/minecraft/server/minecraft_server.%s.jar";
private static final String MAPPING_URL = "https://arclight.mcxk.net/net/minecraft/server/mappings_server.%s.txt";
private static final Map<String, String> VERSION_HASH = Map.of(
"1.19.1", "8399e1211e95faa421c1507b322dbeae86d604df"
"1.19.2", "f69c284232d7c7580bd89a5a4931c3581eae1378"
);
private static final Map<String, String> MAPPING_HASH = Map.of(
"1.19.1", "3565648cdd47ae15738fb804a95a659137d7cfd3"
"1.19.2", "ed5e6e8334ad67f5af0150beed0f3d156d74bd57"
);
public static List<Path> modInstall(Consumer<String> logger) throws Throwable {