Rewrote Camera Movement to only respect previous motion direction | Fixes https://trello.com/c/y7nIqj47/
This commit is contained in:
@@ -42,6 +42,7 @@ public class CameraEntity extends EntityPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Vec3 direction;
|
private Vec3 direction;
|
||||||
|
private Vec3 dirBefore;
|
||||||
private double motion;
|
private double motion;
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
@@ -125,8 +126,6 @@ public class CameraEntity extends EntityPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMovement(MoveDirection dir) {
|
public void setMovement(MoveDirection dir) {
|
||||||
Vec3 oldDir = direction;
|
|
||||||
|
|
||||||
switch(dir) {
|
switch(dir) {
|
||||||
case BACKWARD:
|
case BACKWARD:
|
||||||
direction = this.getVectorForRotation(-rotationPitch, rotationYaw - 180);
|
direction = this.getVectorForRotation(-rotationPitch, rotationYaw - 180);
|
||||||
@@ -148,8 +147,15 @@ public class CameraEntity extends EntityPlayer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oldDir != null)
|
Vec3 dbf = direction;
|
||||||
direction = direction.normalize().add(new Vec3(oldDir.xCoord * (motion / 4f), oldDir.yCoord * (motion / 4f), oldDir.zCoord * (motion / 4f)).normalize());
|
|
||||||
|
if(dirBefore != null) {
|
||||||
|
direction = dirBefore.normalize().add(direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
dirBefore = dbf;
|
||||||
|
|
||||||
|
updateMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveAbsolute(Position pos) {
|
public void moveAbsolute(Position pos) {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class KeyInputHandler {
|
|||||||
boolean speedup = false;
|
boolean speedup = false;
|
||||||
|
|
||||||
if(mc.currentScreen == null) {
|
if(mc.currentScreen == null) {
|
||||||
|
boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
||||||
|
|
||||||
for(KeyBinding kb : keyBindings) {
|
for(KeyBinding kb : keyBindings) {
|
||||||
//don't act on Mouse inputs
|
//don't act on Mouse inputs
|
||||||
if(kb.getKeyCode() < 0) continue;
|
if(kb.getKeyCode() < 0) continue;
|
||||||
@@ -42,37 +44,36 @@ public class KeyInputHandler {
|
|||||||
if(ReplayMod.replaySender.paused() && !Keyboard.isKeyDown(kb.getKeyCode()))
|
if(ReplayMod.replaySender.paused() && !Keyboard.isKeyDown(kb.getKeyCode()))
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(ReplayHandler.isCamera()) {
|
if(ReplayHandler.isCamera()) {
|
||||||
if(kb.getKeyDescription().equals("key.forward")) {
|
if(kb.getKeyDescription().equals("key.forward")) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
forward = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb.getKeyDescription().equals("key.back")) {
|
if(kb.getKeyDescription().equals("key.back")) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
backward = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb.getKeyDescription().equals("key.jump")) {
|
if(kb.getKeyDescription().equals("key.jump")) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
up = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb.getKeyDescription().equals("key.left")) {
|
if(kb.getKeyDescription().equals("key.left")) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
left = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb.getKeyDescription().equals("key.right")) {
|
if(kb.getKeyDescription().equals("key.right")) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
right = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kb.getKeyDescription().equals("key.sneak")) {
|
if(kb.getKeyDescription().equals("key.sneak")) {
|
||||||
if(ReplayHandler.isCamera()) {
|
if(ReplayHandler.isCamera()) {
|
||||||
ReplayHandler.getCameraEntity().setMovement(MoveDirection.DOWN);
|
down = true;
|
||||||
speedup = true;
|
speedup = true;
|
||||||
} else {
|
} else {
|
||||||
ReplayHandler.spectateCamera();
|
ReplayHandler.spectateCamera();
|
||||||
@@ -83,6 +84,8 @@ public class KeyInputHandler {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forwardCameraMovement(forward, backward, left, right, up, down);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ReplayHandler.getCameraEntity() != null) {
|
if(ReplayHandler.getCameraEntity() != null) {
|
||||||
@@ -115,7 +118,26 @@ public class KeyInputHandler {
|
|||||||
handleCustomKeybindings(kb, found, -1);
|
handleCustomKeybindings(kb, found, -1);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forwardCameraMovement(boolean forward, boolean backward, boolean left, boolean right, boolean up, boolean down) {
|
||||||
|
if(forward && !backward) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.FORWARD);
|
||||||
|
} else if(backward && !forward) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.BACKWARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(left && !right) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.LEFT);
|
||||||
|
} else if(right && !left) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(up && !down) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.UP);
|
||||||
|
} else if(down && !up) {
|
||||||
|
ReplayHandler.getCameraEntity().setMovement(MoveDirection.DOWN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCustomKeybindings(KeyBinding kb, boolean found, int keyCode) {
|
public void handleCustomKeybindings(KeyBinding kb, boolean found, int keyCode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user