Add support for rotation argument handling (#12090)
This commit is contained in:
@@ -19,9 +19,11 @@ import io.papermc.paper.command.brigadier.argument.range.RangeProvider;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.BlockPositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.FinePositionResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.PlayerProfileListResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.RotationResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.EntitySelectorArgumentResolver;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||
import io.papermc.paper.entity.LookAnchor;
|
||||
import io.papermc.paper.math.Rotation;
|
||||
import io.papermc.paper.registry.PaperRegistries;
|
||||
import io.papermc.paper.registry.RegistryAccess;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
@@ -61,6 +63,7 @@ import net.minecraft.commands.arguments.TimeArgument;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockStateArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.RotationArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemPredicateArgument;
|
||||
@@ -71,6 +74,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.HeightMap;
|
||||
@@ -156,6 +160,15 @@ public class VanillaArgumentProviderImpl implements VanillaArgumentProvider {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgumentType<RotationResolver> rotation() {
|
||||
return this.wrap(RotationArgument.rotation(), (result) -> sourceStack -> {
|
||||
final Vec2 vec2 = result.getRotation((CommandSourceStack) sourceStack);
|
||||
|
||||
return Rotation.rotation(vec2.y, vec2.x);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgumentType<BlockState> blockState() {
|
||||
return this.wrap(BlockStateArgument.block(PaperCommands.INSTANCE.getBuildContext()), (result) -> {
|
||||
|
||||
Reference in New Issue
Block a user