Skip to content

Commit

Permalink
floating item
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Nov 18, 2023
1 parent 733a0b6 commit 3e7ac8f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = EntityItem.class, remap = false)
public abstract class EntityItemMixin extends Entity {

public EntityItemMixin(World world) {
super(world);
}

@Inject(method = "checkAndHandleWater", at = @At("HEAD"), cancellable = true)
public void checkAndHandleWater(CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(this.world.isMaterialInBB(this.bb, Material.water));
}

@Inject(method = "tick", at = @At("TAIL"))
public void tick(CallbackInfo ci) {
if (this.wasInWater) {
this.yd += 0.1F;
this.yd *= (double) 0.85f;
}
}
}
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 @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"BiomeMixin",
"EntityItemMixin",
"EntityMixin",
"EntityPlayerMixin",
"NetHandlerMixin",
Expand Down

0 comments on commit 3e7ac8f

Please sign in to comment.