Made Camera Movement Speed adjustable by Mousewheel

This commit is contained in:
CrushedPixel
2015-06-03 02:53:30 +02:00
parent 7fed5e8d4d
commit 0dbc18c662
2 changed files with 29 additions and 6 deletions

View File

@@ -18,9 +18,28 @@ import org.lwjgl.Sys;
public class CameraEntity extends EntityPlayer { public class CameraEntity extends EntityPlayer {
private static final double MAX_SPEED = 10; public static final double SPEED_CHANGE = 0.5;
private static final double THRESHOLD = MAX_SPEED / 20; public static final double LOWER_SPEED = 2;
private static final double DECAY = MAX_SPEED/3; public static final double UPPER_SPEED = 20;
private static double MAX_SPEED = 10;
private static double THRESHOLD = MAX_SPEED / 20;
private static double DECAY = MAX_SPEED/3;
public static void modifyCameraSpeed(boolean increase) {
setCameraMaximumSpeed(getCameraMaximumSpeed() + (increase ? 1 : -1) * SPEED_CHANGE);
}
public static void setCameraMaximumSpeed(double maxSpeed) {
if(maxSpeed < LOWER_SPEED || maxSpeed > UPPER_SPEED) return;
MAX_SPEED = maxSpeed;
THRESHOLD = MAX_SPEED / 20;
DECAY = MAX_SPEED/3;
}
public static double getCameraMaximumSpeed() {
return MAX_SPEED;
}
private Vec3 direction; private Vec3 direction;
private double motion; private double motion;
@@ -32,7 +51,6 @@ public class CameraEntity extends EntityPlayer {
private boolean speedup = false; private boolean speedup = false;
public CameraEntity(World worldIn) { public CameraEntity(World worldIn) {
//super(worldIn);
super(worldIn, Minecraft.getMinecraft().getSession().getProfile()); super(worldIn, Minecraft.getMinecraft().getSession().getProfile());
} }

View File

@@ -1,5 +1,6 @@
package eu.crushedpixel.replaymod.events; package eu.crushedpixel.replaymod.events;
import eu.crushedpixel.replaymod.entities.CameraEntity;
import eu.crushedpixel.replaymod.replay.ReplayHandler; import eu.crushedpixel.replaymod.replay.ReplayHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.MouseEvent;
@@ -13,11 +14,15 @@ public class MouseInputHandler {
@SubscribeEvent @SubscribeEvent
public void mouseEvent(MouseEvent event) { public void mouseEvent(MouseEvent event) {
if(!ReplayHandler.isInReplay() || !Mouse.isButtonDown(1)) { if(!ReplayHandler.isInReplay()) {
rightDown = false;
return; return;
} }
if(event.dwheel != 0 && mc.currentScreen == null) {
boolean increase = event.dwheel > 0;
CameraEntity.modifyCameraSpeed(increase);
}
if(Mouse.isButtonDown(1)) { if(Mouse.isButtonDown(1)) {
if(!rightDown) { if(!rightDown) {
rightDown = true; rightDown = true;