Skip to content

Instantly share code, notes, and snippets.

@vercte
Last active November 23, 2025 06:07
Show Gist options
  • Select an option

  • Save vercte/32db6009a0fc76b3f5967abba72a5d3c to your computer and use it in GitHub Desktop.

Select an option

Save vercte/32db6009a0fc76b3f5967abba72a5d3c to your computer and use it in GitHub Desktop.
this mixin is not finding its injection point
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package io.github.apace100.origins.mixin;
import io.github.apace100.apoli.mixin.EntityAccessor;
import io.github.apace100.origins.power.OriginsPowerTypes;
import io.github.apace100.origins.registry.ModDamageSources;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.material.Fluid;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public final class WaterBreathingMixin {
@Mixin({LivingEntity.class})
public abstract static class CanBreatheInWater extends Entity {
public CanBreatheInWater(EntityType<?> type, Level world) {
super(type, world);
}
@Inject(
at = {@At("HEAD")},
method = {"canBreatheInWater"},
cancellable = true
)
public void doWaterBreathing(CallbackInfoReturnable<Boolean> info) {
if (OriginsPowerTypes.WATER_BREATHING.isActive(this)) {
info.setReturnValue(true);
}
}
}
@Mixin({Player.class})
public abstract static class UpdateAir extends LivingEntity {
protected UpdateAir(EntityType<? extends LivingEntity> entityType, Level world) {
super(entityType, world);
}
@Inject(
at = {@At("TAIL")},
method = {"tick"}
)
private void tick(CallbackInfo info) { // I want to mixin here,
if (OriginsPowerTypes.WATER_BREATHING.isActive(this)) {
// to replace this `this.isEyeInFluid`
if (!this.isEyeInFluid(FluidTags.WATER) && !this.hasEffect(MobEffects.WATER_BREATHING) && !this.hasEffect(MobEffects.CONDUIT_POWER)) {
if (!((EntityAccessor)this).callIsBeingRainedOn()) {
int landGain = this.increaseAirSupply(0);
this.setAirSupply(this.decreaseAirSupply(this.getAirSupply()) - landGain);
if (this.getAirSupply() == -20) {
this.setAirSupply(0);
for(int i = 0; i < 8; ++i) {
double f = this.random.nextDouble() - this.random.nextDouble();
double g = this.random.nextDouble() - this.random.nextDouble();
double h = this.random.nextDouble() - this.random.nextDouble();
this.level().addParticle(ParticleTypes.BUBBLE, this.getRandomX((double)0.5F), this.getEyeY() + this.random.nextGaussian() * 0.08, this.getRandomZ((double)0.5F), f * (double)0.5F, g * (double)0.5F + (double)0.25F, h * (double)0.5F);
}
this.hurt(ModDamageSources.getSource(this.damageSources(), ModDamageSources.NO_WATER_FOR_GILLS), 2.0F);
}
} else {
int landGain = this.increaseAirSupply(0);
this.setAirSupply(this.getAirSupply() - landGain);
}
} else if (this.getAirSupply() < this.getMaxAirSupply()) {
this.setAirSupply(this.increaseAirSupply(this.getAirSupply()));
}
}
}
@Redirect(
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerEntity;isSubmergedIn(Lnet/minecraft/registry/tag/TagKey;)Z"
),
method = {"updateTurtleHelmet"}
)
public boolean isSubmergedInProxy(Player player, TagKey<Fluid> fluidTag) {
boolean submerged = this.isEyeInFluid(fluidTag);
if (OriginsPowerTypes.WATER_BREATHING.isActive(this)) {
return !submerged;
} else {
return submerged;
}
}
}
}
package dev.igalaxy.createorigins.mixin;
import com.bawnorton.mixinsquared.TargetHandler;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(value = Player.class, priority = 1500)
public class WaterBreathingUpdateAirMixinSquared {
@TargetHandler(
mixin = "io.github.apace100.origins.mixin.WaterBreathingMixin$UpdateAir",
name = "tick",
prefix = "handler"
)
@ModifyExpressionValue(
method = "@MixinSquared:Handler",
at = @At(
value = "INVOKE",
target = "Lio/github/apace100/origins/mixin/WaterBreathingMixin$UpdateAir;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"
)
)
private boolean headUnderWater(boolean original) {
if (DivingHelmetItem.breatheUnderwater((LivingEntity) (Object) this))
return false;
return original;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment