Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Jan 29, 2024
1 parent 8f87b56 commit 5e77f1a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ loader_version=0.14.19-babric.3-bta

# HalpLibe
halplibe_version=3.1.0
dragonfly_version=1.3.5-7.1
dragonfly_version=1.4.3-7.1
terrain_api_version=1.4.2-7.1
# Mod
mod_version=2.1.0
mod_version=2.2.0
mod_group=baguchan
mod_name=better_with_aquatic
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void beforeGameStart() {
Block.lightBlock[Block.fluidWaterStill.id] = 1;
ModBlocks.createBlocks();
ModItems.onInitialize();

EntityHelper.Core.createEntity(EntityFish.class, entityID, "Fish");
EntityHelper.Core.createEntity(EntityAnglerFish.class, entityID + 1, "AnglerFish");
EntityHelper.Core.createEntity(EntityDrowned.class, entityID + 2, "Drowned");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
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.entity.player.EntityPlayerSP;
import net.minecraft.core.block.material.Material;
import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.util.helper.MathHelper;
import net.minecraft.core.world.World;
Expand All @@ -13,7 +11,6 @@
import org.spongepowered.asm.mixin.Unique;
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;

@Mixin(value = EntityPlayerSP.class, remap = false)
Expand Down Expand Up @@ -84,21 +81,4 @@ protected void checkInTile(double d, double d1, double d2, CallbackInfoReturnabl
cir.setReturnValue(false);
}
}

@Inject(method = "onLivingUpdate", at = @At(value = "TAIL"))
public void onLivingUpdateSwiming(CallbackInfo ci) {
if (this.isUnderLiquid(Material.water) && !this.isSneaking()) {
if (BetterWithAquatic.isEnableSwim() && mc.gameSettings.keySprint.isPressed()) {
if (!this.pressedSprint) {
this.setSwimming(true);
this.pressedSprint = true;
}
} else {
if (this.pressedSprint) {
this.setSwimming(false);
this.pressedSprint = false;
}
}
}
}
}
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;
}
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"0.1667": [
0.5,
1,
10
5
],
"0.4167": [
1,
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/better_with_aquatic.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"client.EntityClientPlayerMPMixin",
"client.EntityPlayerSPMixin",
"client.ModelPlayerMixin",
"client.PlayerInputMixin",
"client.PlayerRendererMixin"
],
"injectors": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"depends": {
"fabricloader": ">=0.13.3",
"halplibe": ">=3.1.0",
"dragonfly": ">=1.3.5-7.1",
"dragonfly": ">=1.4.2-7.1",
"better_ai": ">=2.0.1",
"terrain-api": ">=1.4.2-7.1"
},
Expand Down

0 comments on commit 5e77f1a

Please sign in to comment.