Skip to content

Commit

Permalink
swiming fix
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Jun 5, 2024
1 parent 471c4c5 commit 659bc97
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ halplibe_version=4.0.6
dragonfly_version=1.5.0-7.2-pre1
terrain_api_version=1.4.4-7.2-pre1
# Mod
mod_version=4.0.0
mod_version=4.0.1
mod_group=baguchan
mod_name=better_with_aquatic
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package baguchan.better_with_aquatic.mixin;

import net.minecraft.core.block.material.Material;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.entity.EntityItem;
import net.minecraft.core.world.World;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = EntityItem.class, remap = false)
public abstract class EntityItemMixin extends Entity {
Expand All @@ -14,6 +17,13 @@ public EntityItemMixin(World world) {
super(world);
}

@Inject(method = "checkAndHandleWater", at = @At("HEAD"), cancellable = true)
public void checkAndHandleWater(boolean addVelocity, CallbackInfoReturnable<Boolean> cir) {
Entity entity = (Entity) (Object) this;

cir.setReturnValue(this.world.handleMaterialAcceleration(this.bb, Material.water, entity, addVelocity));
}

@Redirect(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/core/entity/EntityItem;yd:D", ordinal = 7))
public double tick(EntityItem instance) {
if (this.wasInWater) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/baguchan/better_with_aquatic/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package baguchan.better_with_aquatic.mixin;

import net.minecraft.core.block.material.Material;
import net.minecraft.core.entity.Entity;
import net.minecraft.core.util.phys.AABB;
import net.minecraft.core.world.World;
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.CallbackInfoReturnable;

@Mixin(value = Entity.class, remap = false)
public class EntityMixin {
Expand All @@ -14,4 +18,11 @@ public class EntityMixin {
@Shadow
@Final
public AABB bb;

@Inject(method = "checkAndHandleWater", at = @At("HEAD"), cancellable = true)
public void checkAndHandleWater(boolean addVelocity, CallbackInfoReturnable<Boolean> cir) {
Entity entity = (Entity) (Object) this;

cir.setReturnValue(this.world.handleMaterialAcceleration(this.bb, Material.water, entity, addVelocity));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void tick(EntityPlayer entityplayer, CallbackInfo ci) {
--this.sprintTimer;
}
if (entityplayer instanceof ISwiming) {
if (entityplayer.isUnderLiquid(Material.water) && !entityplayer.isSneaking()) {
if (BetterWithAquatic.isEnableSwim() && entityplayer.isUnderLiquid(Material.water) && !entityplayer.isSneaking()) {
if (this.pressedForward) {
if (this.sprintTimer == 0) {
this.sprintTimer = 7;
Expand Down

0 comments on commit 659bc97

Please sign in to comment.