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 -1
View File
@@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=22w17a minecraft_version=22w18a
loader_version=0.13.3 loader_version=0.13.3
fabric_version=0.49.4+1.19 fabric_version=0.49.4+1.19
@@ -1,5 +1,7 @@
package carpet.mixins; 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.network.protocol.game.ServerboundChatPacket;
import net.minecraft.server.network.TextFilter; import net.minecraft.server.network.TextFilter;
import org.spongepowered.asm.mixin.Mixin; 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", @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 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()) 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.MinecraftServer;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.ProfilePublicKey;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; 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; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerPlayer.class) @Mixin(ServerPlayer.class)
public abstract class ServerPlayerMixin implements ServerPlayerEntityInterface public abstract class ServerPlayer_actionPackMixin implements ServerPlayerEntityInterface
{ {
@Unique @Unique
public EntityPlayerActionPack actionPack; public EntityPlayerActionPack actionPack;
@@ -25,11 +26,7 @@ public abstract class ServerPlayerMixin implements ServerPlayerEntityInterface
} }
@Inject(method = "<init>", at = @At(value = "RETURN")) @Inject(method = "<init>", at = @At(value = "RETURN"))
private void onServerPlayerEntityContructor( private void onServerPlayerEntityContructor(MinecraftServer foo, ServerLevel bar, GameProfile baz, ProfilePublicKey qux, CallbackInfo ci)
MinecraftServer minecraftServer_1,
ServerLevel serverWorld_1,
GameProfile gameProfile_1,
CallbackInfo ci)
{ {
this.actionPack = new EntityPlayerActionPack((ServerPlayer) (Object) this); 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.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -38,9 +39,8 @@ public abstract class ServerPlayer_scarpetEventMixin extends Player implements S
@Unique @Unique
private boolean isInvalidReference = false; private boolean isInvalidReference = false;
public ServerPlayer_scarpetEventMixin(Level world, BlockPos blockPos, float f, GameProfile gameProfile) public ServerPlayer_scarpetEventMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
{ super(level, blockPos, f, gameProfile, profilePublicKey);
super(world, blockPos, f, gameProfile);
} }
@Shadow protected abstract void completeUsingItem(); @Shadow protected abstract void completeUsingItem();
@@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@@ -18,8 +19,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerPlayer.class) @Mixin(ServerPlayer.class)
public abstract class ServerPlayer_updateSuppressionCrashFixMixin extends Player { public abstract class ServerPlayer_updateSuppressionCrashFixMixin extends Player {
public ServerPlayer_updateSuppressionCrashFixMixin(Level world, BlockPos pos, float yaw, GameProfile profile) { public ServerPlayer_updateSuppressionCrashFixMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile, ProfilePublicKey profilePublicKey) {
super(world, pos, yaw, profile); super(level, blockPos, f, gameProfile, profilePublicKey);
} }
@Redirect( @Redirect(
@@ -17,6 +17,7 @@ import net.minecraft.server.players.GameProfileCache;
import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.food.FoodData; import net.minecraft.world.food.FoodData;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameType; import net.minecraft.world.level.GameType;
@@ -60,7 +61,7 @@ public class EntityPlayerMPFake extends ServerPlayer
SkullBlockEntity.updateGameprofile(gameprofile, result::set); SkullBlockEntity.updateGameprofile(gameprofile, result::set);
gameprofile = result.get(); 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); instance.fixStartingPosition = () -> instance.moveTo(d0, d1, d2, (float) yaw, (float) pitch);
server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance); server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), instance);
instance.teleportTo(worldIn, d0, d1, d2, (float)yaw, (float)pitch); 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")); player.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
ServerLevel worldIn = player.getLevel();//.getWorld(player.dimension); ServerLevel worldIn = player.getLevel();//.getWorld(player.dimension);
GameProfile gameprofile = player.getGameProfile(); 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); server.getPlayerList().placeNewPlayer(new FakeClientConnection(PacketFlow.SERVERBOUND), playerShadow);
playerShadow.setHealth(player.getHealth()); playerShadow.setHealth(player.getHealth());
@@ -100,9 +101,9 @@ public class EntityPlayerMPFake extends ServerPlayer
return playerShadow; 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; isAShadow = shadow;
} }
@@ -2,6 +2,7 @@ package carpet.script.utils;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import com.mojang.brigadier.ResultConsumer; import com.mojang.brigadier.ResultConsumer;
import net.minecraft.commands.CommandSigningContext;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.commands.arguments.EntityAnchorArgument;
@@ -36,12 +37,13 @@ public class SnoopyCommandSource extends CommandSourceStack
// good stuff // good stuff
private final Component[] error; private final Component[] error;
private final List<Component> chatOutput; private final List<Component> chatOutput;
private final CommandSigningContext signingContext;
public SnoopyCommandSource(CommandSourceStack original, Component[] error, List<Component> chatOutput) public SnoopyCommandSource(CommandSourceStack original, Component[] error, List<Component> chatOutput)
{ {
super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), CarpetSettings.runPermissionLevel, super(CommandSource.NULL, original.getPosition(), original.getRotation(), original.getLevel(), CarpetSettings.runPermissionLevel,
original.getTextName(), original.getDisplayName(), original.getServer(), original.getEntity(), false, 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.output = CommandSource.NULL;
this.position = original.getPosition(); this.position = original.getPosition();
this.world = original.getLevel(); this.world = original.getLevel();
@@ -55,6 +57,7 @@ public class SnoopyCommandSource extends CommandSourceStack
this.rotation = original.getRotation(); this.rotation = original.getRotation();
this.error = error; this.error = error;
this.chatOutput = chatOutput; this.chatOutput = chatOutput;
this.signingContext = original.getSigningContext();
} }
public SnoopyCommandSource(ServerPlayer player, Component[] error, List<Component> output) { 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.rotation = player.getRotationVector(); // not a client call really
this.error = error; this.error = error;
this.chatOutput = output; 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 Component[] error, List<Component> chatOutput
) { ) {
super(output, pos, rot, world, level, super(output, pos, rot, world, level,
simpleName, name, server, entity, false, simpleName, name, server, entity, false,
consumer, entityAnchor); consumer, entityAnchor, context);
this.output = output; this.output = output;
this.position = pos; this.position = pos;
this.rotation = rot; this.rotation = rot;
@@ -96,30 +100,31 @@ public class SnoopyCommandSource extends CommandSourceStack
this.entityAnchor = entityAnchor; this.entityAnchor = entityAnchor;
this.error = error; this.error = error;
this.chatOutput = chatOutput; this.chatOutput = chatOutput;
this.signingContext = context;
} }
@Override @Override
public CommandSourceStack withEntity(Entity entity) 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 @Override
public CommandSourceStack withPosition(Vec3 position) 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 @Override
public CommandSourceStack withRotation(Vec2 rotation) 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 @Override
public CommandSourceStack withCallback(ResultConsumer<CommandSourceStack> consumer) 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 @Override
@@ -148,7 +153,12 @@ public class SnoopyCommandSource extends CommandSourceStack
@Override @Override
public CommandSourceStack withAnchor(EntityAnchorArgument.Anchor anchor) 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 @Override
@@ -156,7 +166,7 @@ public class SnoopyCommandSource extends CommandSourceStack
{ {
double d = DimensionType.getTeleportationScale(this.world.dimensionType(), world.dimensionType()); double d = DimensionType.getTeleportationScale(this.world.dimensionType(), world.dimensionType());
Vec3 position = new Vec3(this.position.x * d, this.position.y, this.position.z * d); 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 @Override
+1 -1
View File
@@ -64,7 +64,7 @@
"ExperienceOrb_xpNoCooldownMixin", "ExperienceOrb_xpNoCooldownMixin",
"Player_xpNoCooldownMixin", "Player_xpNoCooldownMixin",
"ServerboundPlayerActionPacketMixin", "ServerboundPlayerActionPacketMixin",
"ServerPlayerMixin", "ServerPlayer_actionPackMixin",
"PlayerList_coreMixin", "PlayerList_coreMixin",
"PlayerList_fakePlayersMixin", "PlayerList_fakePlayersMixin",
"RedstoneWireBlock_fastMixin", "RedstoneWireBlock_fastMixin",