Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
GT3CH1 committed Mar 16, 2023
1 parent c92dc23 commit afe49d3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/peasenet/main/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.nio.file.Paths

/**
* @author gt3ch1
* @version 03-02-2023
* @version 03-16-2023
* A class that contains all the settings for the mod.
*/
object Settings {
Expand Down Expand Up @@ -130,7 +130,7 @@ object Settings {
/**
* Gets the file path to the settings file.
*/
private get() {
get() {
val runDir = GavinsModClient.minecraftClient.runDirectory.absolutePath
val modsDir = "$runDir/mods"
// ensure the gavinsmod folder exists
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/com/peasenet/mixins/MixinPlayerEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ class MixinPlayerEntity {
)
)
fun doNoClip(p: PlayerEntity, noClip: Boolean) {
var noClip = noClip
p.noClip = isEnabled(Type.NO_CLIP)
//NOTE: This is fine. It is required for fabric to work.
noClip = p.noClip
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/peasenet/mods/movement/ModAntiTrample.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import net.minecraft.block.Blocks
class ModAntiTrample : Mod(Type.ANTI_TRAMPLE) {
override fun onTick() {
// check if the player is on farmland by looking at the block below the player.
if (client.player() == null)
return
val player = client.player()
val playerLoc = player.blockPos
val playerLocDown = player.blockPos.down()
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/peasenet/mods/movement/ModAutoJump.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ import com.peasenet.mods.Type

/**
* @author gt3ch1
* @version 03-02-2023
* @version 03-16-2023
* A mod that allows the player to jump as if they were pressing the jump key.
*/
class ModAutoJump : Mod(Type.AUTO_JUMP) {
override fun onTick() {
if (client.player() == null)
return
val player = client.player()
if (player.isOnGround) player.jump()
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/peasenet/mods/movement/ModSpeed.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@ package com.peasenet.mods.movement

import com.peasenet.mods.Mod
import com.peasenet.mods.Type
import kotlin.math.pow
import kotlin.math.sqrt

/**
* @author gt3ch1
* @version 03-02-2023
* @version 03-16-2023
*/
class ModSpeed : Mod(Type.SPEED) {
override fun onTick() {
if (client.player() == null) return
val player = client.player()

if (player.isSneaking) return
if (!player.isOnGround) return
var velocity = player.velocity
velocity = velocity.multiply(1.5)
val currentSpeed = Math.sqrt(Math.pow(velocity.x, 2.0) + Math.pow(velocity.z, 2.0))
val currentSpeed = sqrt(velocity.x.pow(2.0) + velocity.z.pow(2.0))
player.velocity = velocity
if (currentSpeed > 0.5) player.velocity = velocity.multiply(0.5 / currentSpeed)
}
Expand Down

0 comments on commit afe49d3

Please sign in to comment.