Skip to content

Commit

Permalink
Fix permission lost on respawn (#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jan 1, 2025
1 parent 320a09a commit c39bcb4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ public interface ServerLoginNetHandlerBridge extends ServerCommonPacketListenerB

void bridge$preLogin(GameProfile authenticatedProfile) throws Exception;

default FriendlyByteBuf bridge$getDiscardedQueryAnswerData(ServerboundCustomQueryAnswerPacket payload) {
return new FriendlyByteBuf(((ArclightCustomQueryAnswerPayload) payload.payload()).buf());
default FriendlyByteBuf bridge$getDiscardedQueryAnswerData(ServerboundCustomQueryAnswerPacket packet) {
return packet.payload() instanceof ArclightCustomQueryAnswerPayload payload
? new FriendlyByteBuf(payload.buf())
: null;
}

default void bridge$platform$onCustomQuery(ServerboundCustomQueryAnswerPacket payload) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,10 @@ public void reset() {
private void arclight$exhauseCause6(double p_36379_, double p_36380_, double p_36381_, CallbackInfo ci) {
bridge$pushExhaustReason(EntityExhaustionEvent.ExhaustionReason.WALK);
}

@Inject(method = "restoreFrom", at = @At("HEAD"))
private void arclight$forwardHandle(ServerPlayer serverPlayer, boolean bl, CallbackInfo ci) {
((InternalEntityBridge) serverPlayer).internal$getBukkitEntity().setHandle((Entity) (Object) this);
((EntityBridge) this).bridge$setBukkitEntity(((InternalEntityBridge) serverPlayer).internal$getBukkitEntity());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.spongepowered.asm.mixin.Shadow;
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.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand Down Expand Up @@ -80,7 +79,7 @@ public abstract class ServerPlayerGameModeMixin implements PlayerInteractionMana
}
}

@Redirect(method = "handleBlockBreakAction", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V"),
@Decorate(method = "handleBlockBreakAction", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;send(Lnet/minecraft/network/protocol/Packet;)V"),
slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;mayInteract(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;)Z")))
private void arclight$mayNotInteractEvent(ServerGamePacketListenerImpl instance, Packet<?> packet, BlockPos blockPos, ServerboundPlayerActionPacket.Action action, Direction direction) throws Throwable {
CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockPos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
public abstract class ServerLoginNetHandlerMixin_Fabric implements ServerLoginNetHandlerBridge, NetworkHandlerExtensions {

@Override
public FriendlyByteBuf bridge$getDiscardedQueryAnswerData(ServerboundCustomQueryAnswerPacket payload) {
if (payload.payload() instanceof PacketByteBufLoginQueryResponse query) {
public FriendlyByteBuf bridge$getDiscardedQueryAnswerData(ServerboundCustomQueryAnswerPacket packet) {
if (packet.payload() instanceof PacketByteBufLoginQueryResponse query) {
return new FriendlyByteBuf(Unpooled.wrappedBuffer(Unpooled.copyBoolean(true), query.data().slice()));
}
return null;
Expand Down

0 comments on commit c39bcb4

Please sign in to comment.