generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/baguchan/better_with_aquatic/mixin/client/PlayerInputMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package baguchan.better_with_aquatic.mixin.client; | ||
|
||
import baguchan.better_with_aquatic.BetterWithAquatic; | ||
import baguchan.better_with_aquatic.api.ISwiming; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.input.PlayerInput; | ||
import net.minecraft.client.option.GameSettings; | ||
import net.minecraft.core.block.material.Material; | ||
import net.minecraft.core.entity.player.EntityPlayer; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = PlayerInput.class, remap = false) | ||
public class PlayerInputMixin { | ||
|
||
private int sprintTime = 20; | ||
private boolean pressedSprint = false; | ||
@Shadow | ||
@Final | ||
private GameSettings gameSettings; | ||
@Shadow | ||
private boolean pressedForward; | ||
@Shadow | ||
@Final | ||
public Minecraft mc; | ||
|
||
@Inject(method = "tick", at = @At(value = "TAIL")) | ||
public void tick(EntityPlayer entityplayer, CallbackInfo ci) { | ||
|
||
if (entityplayer instanceof ISwiming) { | ||
if (entityplayer.isUnderLiquid(Material.water) && !entityplayer.isSneaking()) { | ||
if (this.pressedForward) { | ||
if (this.sprintTime < 9 && !this.pressedSprint) { | ||
if (BetterWithAquatic.isEnableSwim()) { | ||
((ISwiming) entityplayer).setSwimming(true); | ||
} | ||
} else { | ||
this.pressedSprint = true; | ||
} | ||
this.sprintTime = 0; | ||
} else { | ||
if (this.sprintTime < 20) { | ||
this.sprintTime++; | ||
} | ||
this.pressedSprint = false; | ||
} | ||
|
||
if (BetterWithAquatic.isEnableSwim() && mc.gameSettings.keySprint.isPressed()) { | ||
if (!this.pressedSprint) { | ||
((ISwiming) entityplayer).setSwimming(true); | ||
this.pressedSprint = true; | ||
} | ||
} else { | ||
if (this.pressedSprint) { | ||
//this.setSwimming(false); | ||
this.pressedSprint = false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,7 +210,7 @@ | |
"0.1667": [ | ||
0.5, | ||
1, | ||
10 | ||
5 | ||
], | ||
"0.4167": [ | ||
1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters