Skip to content

Commit

Permalink
- Added 'Disable on Damage' setting
Browse files Browse the repository at this point in the history
- Reordered settings
  • Loading branch information
hashalite committed Mar 3, 2022
1 parent ea2c8e6 commit 03076fb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
19 changes: 11 additions & 8 deletions src/main/java/net/xolt/freecam/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@ public static void init() {
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public FlightMode flightMode = FlightMode.DEFAULT;

@Comment("Changes the horizontal speed of freecam.")
@Comment("The horizontal speed of freecam.")
public double horizontalSpeed = 1.0;

@Comment("Changes the vertical speed of freecam.")
@Comment("The vertical speed of freecam.")
public double verticalSpeed = 0.8;

@Comment("Toggles whether you can break blocks while freecam is enabled.")
public boolean allowBlockBreak = true;

@Comment("Toggles whether you can interact with entities while freecam is enabled.")
public boolean allowEntityInteract = true;

@Comment("Toggles whether your player is rendered in your original position while freecam is enabled.")
public boolean showPlayer = true;

@Comment("Toggles whether your hand is shown while freecam is enabled.")
public boolean showHand = false;

@Comment("Toggles whether taking damage disables freecam.")
public boolean disableOnDamage = true;

@Comment("Toggles whether you can break blocks while freecam is enabled.")
public boolean allowBlockBreak = true;

@Comment("Toggles whether you can interact with entities while freecam is enabled.")
public boolean allowEntityInteract = true;

@Comment("Toggles action bar notifications.")
public boolean notify = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import net.minecraft.client.network.ClientPlayerEntity;
import net.xolt.freecam.Freecam;
import net.xolt.freecam.config.ModConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import static net.xolt.freecam.Freecam.MC;
Expand All @@ -18,4 +20,11 @@ private void onIsCamera(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(true);
}
}

@Inject(method = "damage", at = @At("HEAD"))
private void onDamage(CallbackInfoReturnable<Boolean> cir) {
if (Freecam.isEnabled() && ModConfig.INSTANCE.disableOnDamage && this.equals(MC.player)) {
Freecam.toggle();
}
}
}
5 changes: 3 additions & 2 deletions src/main/resources/assets/freecam/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"text.autoconfig.freecam.option.flightMode": "Flight Mode",
"text.autoconfig.freecam.option.horizontalSpeed": "Horizontal Speed",
"text.autoconfig.freecam.option.verticalSpeed": "Vertical Speed",
"text.autoconfig.freecam.option.showPlayer": "Show Player",
"text.autoconfig.freecam.option.showHand": "Show Hand",
"text.autoconfig.freecam.option.disableOnDamage": "Disable on Damage",
"text.autoconfig.freecam.option.allowBlockBreak": "Allow Breaking Blocks",
"text.autoconfig.freecam.option.allowEntityInteract": "Allow Entity Interaction",
"text.autoconfig.freecam.option.showHand": "Show Hand",
"text.autoconfig.freecam.option.showPlayer": "Show Player",
"text.autoconfig.freecam.option.notify": "Notifications",
"text.autoconfig.freecam.option.enableMessage": "Enable Message",
"text.autoconfig.freecam.option.disableMessage": "Disable Message"
Expand Down

0 comments on commit 03076fb

Please sign in to comment.