Added Entity#setPose

This commit is contained in:
themode 2020-12-29 00:04:15 +01:00
parent 32b8d83ac9
commit cecf6310ca
3 changed files with 32 additions and 8 deletions

View File

@ -41,7 +41,7 @@ public final class CommandManager {
public static final String COMMAND_PREFIX = "/";
private volatile boolean running;
private volatile boolean running = true;
private final ConsoleSender consoleSender = new ConsoleSender();
@ -51,7 +51,6 @@ public final class CommandManager {
private CommandCallback unknownCommandCallback;
public CommandManager() {
running = true;
// Setup console thread
Thread consoleThread = new Thread(() -> {
BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));

View File

@ -1136,9 +1136,33 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
* @param sneaking true to make the entity sneak
*/
public void setSneaking(boolean sneaking) {
this.crouched = sneaking;
this.pose = sneaking ? Pose.SNEAKING : Pose.STANDING;
sendMetadataIndex(0);
setPose(sneaking ? Pose.SNEAKING : Pose.STANDING);
sendMetadataIndex(0); // update the crouched metadata
}
/**
* Gets the current entity pose.
*
* @return the entity pose
*/
@NotNull
public Pose getPose() {
return pose;
}
/**
* Changes the entity pose.
* <p>
* The internal {@code crouched} and {@code swimming} field will be
* updated accordingly.
*
* @param pose the new entity pose
*/
@NotNull
public void setPose(@NotNull Pose pose) {
this.crouched = pose == Pose.SNEAKING;
this.swimming = pose == Pose.SWIMMING;
this.pose = pose;
sendMetadataIndex(6);
}
@ -1159,6 +1183,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
*
* @return the current position of the entity
*/
@NotNull
public Position getPosition() {
return position;
}

View File

@ -86,9 +86,9 @@ public class WindowListener {
}
// Prevent the player from picking a ghost item in cursor
//if (!successful) {
refreshCursorItem(player, inventory);
//}
if (!successful) {
refreshCursorItem(player, inventory);
}
WindowConfirmationPacket windowConfirmationPacket = new WindowConfirmationPacket();
windowConfirmationPacket.windowId = windowId;