Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit c9378fb

Browse files
committed
Order events in order how they would occur
1 parent 90f7e9f commit c9378fb

File tree

1 file changed

+57
-46
lines changed

1 file changed

+57
-46
lines changed

src/main/java/nl/pascalroeleven/minecraft/mineshotrevived/client/OrthoViewHandler.java

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,30 @@ public class OrthoViewHandler {
3838
private static final float ROTATE_SPEED = 4;
3939
private static final float SECONDS_PER_TICK = 1f / 20f;
4040

41-
private final KeyBinding keyToggle = new KeyBinding("key.mineshotrevived.ortho.toggle", GLFW_KEY_KP_5, KEY_CATEGORY);
42-
private final KeyBinding keyZoomIn = new KeyBinding("key.mineshotrevived.ortho.zoom_in", GLFW_KEY_KP_ADD, KEY_CATEGORY);
41+
private final KeyBinding keyToggle = new KeyBinding("key.mineshotrevived.ortho.toggle", GLFW_KEY_KP_5,
42+
KEY_CATEGORY);
43+
private final KeyBinding keyZoomIn = new KeyBinding("key.mineshotrevived.ortho.zoom_in", GLFW_KEY_KP_ADD,
44+
KEY_CATEGORY);
4345
private final KeyBinding keyZoomOut = new KeyBinding("key.mineshotrevived.ortho.zoom_out", GLFW_KEY_KP_SUBTRACT,
4446
KEY_CATEGORY);
45-
private final KeyBinding keyRotateL = new KeyBinding("key.mineshotrevived.ortho.rotate_l", GLFW_KEY_KP_4, KEY_CATEGORY);
46-
private final KeyBinding keyRotateR = new KeyBinding("key.mineshotrevived.ortho.rotate_r", GLFW_KEY_KP_6, KEY_CATEGORY);
47-
private final KeyBinding keyRotateU = new KeyBinding("key.mineshotrevived.ortho.rotate_u", GLFW_KEY_KP_8, KEY_CATEGORY);
48-
private final KeyBinding keyRotateD = new KeyBinding("key.mineshotrevived.ortho.rotate_d", GLFW_KEY_KP_2, KEY_CATEGORY);
49-
private final KeyBinding keyRotateT = new KeyBinding("key.mineshotrevived.ortho.rotate_t", GLFW_KEY_KP_7, KEY_CATEGORY);
50-
private final KeyBinding keyRotateF = new KeyBinding("key.mineshotrevived.ortho.rotate_f", GLFW_KEY_KP_1, KEY_CATEGORY);
51-
private final KeyBinding keyRotateS = new KeyBinding("key.mineshotrevived.ortho.rotate_s", GLFW_KEY_KP_3, KEY_CATEGORY);
52-
private final KeyBinding keyClip = new KeyBinding("key.mineshotrevived.ortho.clip", GLFW_KEY_KP_MULTIPLY, KEY_CATEGORY);
53-
private final KeyBinding keyMod = new KeyBinding("key.mineshotrevived.ortho.mod", GLFW_KEY_LEFT_CONTROL, KEY_CATEGORY);
47+
private final KeyBinding keyRotateL = new KeyBinding("key.mineshotrevived.ortho.rotate_l", GLFW_KEY_KP_4,
48+
KEY_CATEGORY);
49+
private final KeyBinding keyRotateR = new KeyBinding("key.mineshotrevived.ortho.rotate_r", GLFW_KEY_KP_6,
50+
KEY_CATEGORY);
51+
private final KeyBinding keyRotateU = new KeyBinding("key.mineshotrevived.ortho.rotate_u", GLFW_KEY_KP_8,
52+
KEY_CATEGORY);
53+
private final KeyBinding keyRotateD = new KeyBinding("key.mineshotrevived.ortho.rotate_d", GLFW_KEY_KP_2,
54+
KEY_CATEGORY);
55+
private final KeyBinding keyRotateT = new KeyBinding("key.mineshotrevived.ortho.rotate_t", GLFW_KEY_KP_7,
56+
KEY_CATEGORY);
57+
private final KeyBinding keyRotateF = new KeyBinding("key.mineshotrevived.ortho.rotate_f", GLFW_KEY_KP_1,
58+
KEY_CATEGORY);
59+
private final KeyBinding keyRotateS = new KeyBinding("key.mineshotrevived.ortho.rotate_s", GLFW_KEY_KP_3,
60+
KEY_CATEGORY);
61+
private final KeyBinding keyClip = new KeyBinding("key.mineshotrevived.ortho.clip", GLFW_KEY_KP_MULTIPLY,
62+
KEY_CATEGORY);
63+
private final KeyBinding keyMod = new KeyBinding("key.mineshotrevived.ortho.mod", GLFW_KEY_LEFT_CONTROL,
64+
KEY_CATEGORY);
5465

5566
private boolean enabled;
5667
private boolean freeCam;
@@ -137,6 +148,29 @@ private boolean modifierKeyPressed() {
137148
return keyMod.isKeyDown();
138149
}
139150

151+
private void updateZoomAndRotation(double multi) {
152+
if (keyZoomIn.isKeyDown()) {
153+
zoom *= 1 - ZOOM_STEP * multi;
154+
}
155+
if (keyZoomOut.isKeyDown()) {
156+
zoom *= 1 + ZOOM_STEP * multi;
157+
}
158+
159+
if (keyRotateL.isKeyDown()) {
160+
yRot += ROTATE_STEP * multi;
161+
}
162+
if (keyRotateR.isKeyDown()) {
163+
yRot -= ROTATE_STEP * multi;
164+
}
165+
166+
if (keyRotateU.isKeyDown()) {
167+
xRot += ROTATE_STEP * multi;
168+
}
169+
if (keyRotateD.isKeyDown()) {
170+
xRot -= ROTATE_STEP * multi;
171+
}
172+
}
173+
140174
@SubscribeEvent
141175
public void onKeyInput(InputEvent.KeyInputEvent evt) {
142176
boolean mod = modifierKeyPressed();
@@ -173,36 +207,25 @@ public void onKeyInput(InputEvent.KeyInputEvent evt) {
173207
}
174208
}
175209

176-
private void updateZoomAndRotation(double multi) {
177-
if (keyZoomIn.isKeyDown()) {
178-
zoom *= 1 - ZOOM_STEP * multi;
179-
}
180-
if (keyZoomOut.isKeyDown()) {
181-
zoom *= 1 + ZOOM_STEP * multi;
182-
}
183-
184-
if (keyRotateL.isKeyDown()) {
185-
yRot += ROTATE_STEP * multi;
186-
}
187-
if (keyRotateR.isKeyDown()) {
188-
yRot -= ROTATE_STEP * multi;
210+
@SubscribeEvent
211+
public void onClientTickEvent(final ClientTickEvent event) {
212+
if (!enabled || event.phase != Phase.START) {
213+
return;
189214
}
190215

191-
if (keyRotateU.isKeyDown()) {
192-
xRot += ROTATE_STEP * multi;
193-
}
194-
if (keyRotateD.isKeyDown()) {
195-
xRot -= ROTATE_STEP * multi;
196-
}
216+
tick++;
197217
}
198218

199219
@SubscribeEvent
200-
public void onClientTickEvent(final ClientTickEvent event) {
201-
if (!enabled || event.phase != Phase.START) {
220+
public void cameraSetup(CameraSetup event) {
221+
if (!enabled) {
202222
return;
203223
}
204224

205-
tick++;
225+
if (!freeCam) {
226+
event.setPitch(xRot);
227+
event.setYaw(yRot + 180);
228+
}
206229
}
207230

208231
@SubscribeEvent
@@ -232,16 +255,4 @@ public void onFogDensity(EntityViewRenderEvent.FogDensity evt) {
232255
RenderSystem.loadIdentity();
233256
RenderSystem.ortho(-width, width, -height, height, clip ? 0 : -9999, 9999);
234257
}
235-
236-
@SubscribeEvent
237-
public void cameraSetup(CameraSetup event) {
238-
if (!enabled) {
239-
return;
240-
}
241-
242-
if (!freeCam) {
243-
event.setPitch(xRot);
244-
event.setYaw(yRot + 180);
245-
}
246-
}
247-
}
258+
}

0 commit comments

Comments
 (0)