Skip to content

Commit

Permalink
Fixed #61
Browse files Browse the repository at this point in the history
  • Loading branch information
hashalite committed Dec 19, 2022
1 parent aab7bf8 commit 344bf9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/main/java/net/xolt/freecam/Freecam.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Freecam implements ClientModInitializer {
private static boolean freecamEnabled = false;
private static boolean tripodEnabled = false;
private static boolean playerControlEnabled = false;
private static boolean disableNextTick = false;
private static Integer activeTripod = null;
private static FreeCamera freeCamera;
private static HashMap<Integer, FreecamPosition> overworld_tripods = new HashMap<>();
Expand Down Expand Up @@ -254,6 +255,14 @@ public static KeyBinding getTripodResetBind() {
return tripodResetBind;
}

public static boolean disableNextTick() {
return disableNextTick;
}

public static void setDisableNextTick(boolean damage) {
disableNextTick = damage;
}

public static boolean isEnabled() {
return freecamEnabled || tripodEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ private void onIsCamera(CallbackInfoReturnable<Boolean> cir) {
// Disables freecam upon receiving damage if disableOnDamage is enabled.
@Inject(method = "damage", at = @At("HEAD"))
private void onDamage(CallbackInfoReturnable<Boolean> cir) {
if (ModConfig.INSTANCE.disableOnDamage && this.equals(MC.player)) {
if (Freecam.isEnabled()) {
Freecam.toggle();
}
if (Freecam.isEnabled() && ModConfig.INSTANCE.disableOnDamage && this.equals(MC.player)) {
Freecam.setDisableNextTick(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ private void onTick(CallbackInfo ci) {
MC.player.input = input;
}
MC.gameRenderer.setRenderHand(ModConfig.INSTANCE.showHand);

if (Freecam.disableNextTick()) {
Freecam.toggle();
Freecam.setDisableNextTick(false);
}
}
}

Expand Down

0 comments on commit 344bf9e

Please sign in to comment.