mirror of
https://github.com/FabricMC/fabric.git
synced 2025-02-16 19:59:56 -05:00
Add client command source properties (#1518)
* Add extra fields to FabricClientCommandSource * Re-add `getPlayer` * Fix style errors * Make the meta property a `Map` * Update Javadoc * Implement requested changes * Fix styling errors * Implement requested changes * Implement requested changes * Implement requested changes
This commit is contained in:
parent
25611bb75a
commit
fc9d06d347
1 changed files with 42 additions and 0 deletions
|
@ -20,7 +20,10 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -58,10 +61,49 @@ public interface FabricClientCommandSource extends CommandSource {
|
|||
*/
|
||||
ClientPlayerEntity getPlayer();
|
||||
|
||||
/**
|
||||
* Gets the entity that used the command.
|
||||
*
|
||||
* @return the entity
|
||||
*/
|
||||
default Entity getEntity() {
|
||||
return getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the position from where the command has been executed.
|
||||
*
|
||||
* @return the position
|
||||
*/
|
||||
default Vec3d getPosition() {
|
||||
return getPlayer().getPos();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rotation of the entity that used the command.
|
||||
*
|
||||
* @return the rotation
|
||||
*/
|
||||
default Vec2f getRotation() {
|
||||
return getPlayer().getRotationClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the world where the player used the command.
|
||||
*
|
||||
* @return the world
|
||||
*/
|
||||
ClientWorld getWorld();
|
||||
|
||||
/**
|
||||
* Gets the meta property under {@code key} that was assigned to this source.
|
||||
*
|
||||
* <p>This method should return the same result for every call with the same {@code key}.
|
||||
*
|
||||
* @param key the meta key
|
||||
* @return the meta
|
||||
*/
|
||||
default Object getMeta(String key) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue