This commit is contained in:
gnembon committed 2022-05-04 21:34:22 +02:00
1 parent 544c1a8327
commit 217567c037
8 files changed
+40 -29

No files matched your search

@@ -1,5 +1,7 @@
package carpet.mixins;
import net.minecraft.network.chat.MessageSignature;
import net.minecraft.network.chat.SignedMessage;
import net.minecraft.network.protocol.game.ServerboundChatPacket;
import net.minecraft.server.network.TextFilter;
import org.spongepowered.asm.mixin.Mixin;
@@ -284,13 +286,13 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin
}
@Inject(method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;Lnet/minecraft/server/network/TextFilter$FilteredText;)V",
at = @At(value = "INVOKE", target = "Ljava/lang/String;startsWith(Ljava/lang/String;)Z"),
at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/SignedMessage;Lnet/minecraft/server/network/TextFilter$FilteredText;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/resources/ResourceKey;)V"),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void onChatMessage(ServerboundChatPacket serverboundChatPacket, TextFilter.FilteredText filteredText, CallbackInfo ci, String string) {
private void onChatMessage(ServerboundChatPacket serverboundChatPacket, TextFilter.FilteredText filteredText, CallbackInfo ci, MessageSignature messageSignature, SignedMessage signedMessage) {
if (PLAYER_MESSAGE.isNeeded())
{
PLAYER_MESSAGE.onPlayerMessage(player,string);
PLAYER_MESSAGE.onPlayerMessage(player, filteredText.getRaw());
}
}
}
@@ -7,6 +7,7 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.ProfilePublicKey;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -14,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerPlayer.class)
public abstract class ServerPlayerMixin implements ServerPlayerEntityInterface
public abstract class ServerPlayer_actionPackMixin implements ServerPlayerEntityInterface
{
@Unique
public EntityPlayerActionPack actionPack;
@@ -25,11 +26,7 @@ public abstract class ServerPlayerMixin implements ServerPlayerEntityInterface
}
@Inject(method = "<init>", at = @At(value = "RETURN"))
private void onServerPlayerEntityContructor(
MinecraftServer minecraftServer_1,
ServerLevel serverWorld_1,
GameProfile gameProfile_1,
CallbackInfo ci)
private void onServerPlayerEntityContructor(MinecraftServer foo, ServerLevel bar, GameProfile baz, ProfilePublicKey qux, CallbackInfo ci)
{
this.actionPack = new EntityPlayerActionPack((ServerPlayer) (Object) this);
}
@@ -14,6 +14,7 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
@@ -38,9 +39,8 @@ public abstract class ServerPlayer_scarpetEventMixin extends Player implements S
@Unique
private boolean isInvalidReference = false;
public ServerPlayer_scarpetEventMixin(Level world, BlockPos blockPos, float f, GameProfile gameProfile)
{
super(world, blockPos, f, gameProfile);
public ServerPlayer_scarpetEventMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
super(level, blockPos, f, gameProfile, profilePublicKey);
}
@Shadow protected abstract void completeUsingItem();
@@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -18,8 +19,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerPlayer.class)
public abstract class ServerPlayer_updateSuppressionCrashFixMixin extends Player {
public ServerPlayer_updateSuppressionCrashFixMixin(Level world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
public ServerPlayer_updateSuppressionCrashFixMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
super(level, blockPos, f, gameProfile, profilePublicKey);
}
@Redirect(
@@ -17,6 +17,7 @@ import net.minecraft.server.players.GameProfileCache;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType;
@@ -60,7 +61,7 @@ public class EntityPlayerMPFake extends ServerPlayer
SkullBlockEntity.updateGameprofile(gameprofile, result::set);
gameprofile = result.get();
}
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false);
EntityPlayerMPFake instance = new EntityPlayerMPFake(server, worldIn, gameprofile, false, null);
instance.fixStartingPosition = () -> instance.moveTo(d0, d1, d2, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance);
instance.teleportTo(worldIn, d0, d1, d2, (float)yaw, (float)pitch);
@@ -82,7 +83,7 @@ public class EntityPlayerMPFake extends ServerPlayer
player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
ServerLevel worldIn = player.getLevel();//.getWorld(player.dimension);
GameProfile gameprofile = player.getGameProfile();
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true);
EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, true, player.getProfilePublicKey());
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow);
playerShadow.setHealth(player.getHealth());
@@ -100,9 +101,9 @@ public class EntityPlayerMPFake extends ServerPlayer
return playerShadow;
}
private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, boolean shadow)
private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, boolean shadow, ProfilePublicKey profilePublicKey)
{
super(server, worldIn, profile);
super(server, worldIn, profile, profilePublicKey);
isAShadow = shadow;
}
@@ -2,6 +2,7 @@ package carpet.script.utils;
import carpet.CarpetSettings;
import com.mojang.brigadier.ResultConsumer;
import net.minecraft.commands.CommandSigningContext;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityAnchorArgument;
@@ -36,12 +37,13 @@ public class SnoopyCommandSource extends CommandSourceStack
// good stuff
private final Component[] error;
private final List<Component> chatOutput;
private final CommandSigningContext signingContext;
public SnoopyCommandSource(CommandSourceStack original, Component[] error, List<Component> chatOutput)
{
super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), CarpetSettings.runPermissionLevel,
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity(), false,
(ctx, succ, res) -> { }, EntityAnchorArgument.Anchor.FEET);
(ctx, succ, res) -> { }, EntityAnchorArgument.Anchor.FEET, CommandSigningContext.NONE);
this.output = CommandSource.NULL;
this.position = original.getPosition();
this.world = original.getLevel();
@@ -55,6 +57,7 @@ public class SnoopyCommandSource extends CommandSourceStack
this.rotation = original.getRotation();
this.error = error;
this.chatOutput = chatOutput;
this.signingContext = original.getSigningContext();
}
public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output) {
@@ -75,14 +78,15 @@ public class SnoopyCommandSource extends CommandSourceStack
this.rotation = player.getRotationVector(); // not a client call really
this.error = error;
this.chatOutput = output;
this.signingContext = CommandSigningContext.NONE;
}
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, ResultConsumer<CommandSourceStack> consumer, EntityAnchorArgument.Anchor entityAnchor,
private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, ResultConsumer<CommandSourceStack> consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context,
Component[] error, List<Component> chatOutput
) {
super(output, pos, rot, world, level,
simpleName, name, server, entity, false,
consumer, entityAnchor);
consumer, entityAnchor, context);
this.output = output;
this.position = pos;
this.rotation = rot;
@@ -96,30 +100,31 @@ public class SnoopyCommandSource extends CommandSourceStack
this.entityAnchor = entityAnchor;
this.error = error;
this.chatOutput = chatOutput;
this.signingContext = context;
}
@Override
public CommandSourceStack withEntity(Entity entity)
{
return new SnoopyCommandSource(output, position, rotation, world, level, entity.getName().getString(), entity.getDisplayName(), server, entity, resultConsumer, entityAnchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, entity.getName().getString(), entity.getDisplayName(), server, entity, resultConsumer, entityAnchor, signingContext, error, chatOutput);
}
@Override
public CommandSourceStack withPosition(Vec3 position)
{
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, error, chatOutput);
}
@Override
public CommandSourceStack withRotation(Vec2 rotation)
{
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, error, chatOutput);
}
@Override
public CommandSourceStack withCallback(ResultConsumer<CommandSourceStack> consumer)
{
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, consumer, entityAnchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, consumer, entityAnchor, signingContext, error, chatOutput);
}
@Override
@@ -148,7 +153,12 @@ public class SnoopyCommandSource extends CommandSourceStack
@Override
public CommandSourceStack withAnchor(EntityAnchorArgument.Anchor anchor)
{
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, anchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, anchor, signingContext, error, chatOutput);
}
@Override
public CommandSourceStack withSigningContext(CommandSigningContext commandSigningContext) {
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, commandSigningContext, error, chatOutput);
}
@Override
@@ -156,7 +166,7 @@ public class SnoopyCommandSource extends CommandSourceStack
{
double d = DimensionType.getTeleportationScale(this.world.dimensionType(), world.dimensionType());
Vec3 position = new Vec3(this.position.x * d, this.position.y, this.position.z * d);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, error, chatOutput);
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, resultConsumer, entityAnchor, signingContext, error, chatOutput);
}
@Override