25 lines
1.0 KiB
Java
25 lines
1.0 KiB
Java
package ru.bitheaven.createairfabric.mixin;
|
|
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
|
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
|
import ru.bitheaven.createairfabric.CreateAirFabric;
|
|
|
|
@Mixin(DivingHelmetItem.class)
|
|
public abstract class DivingHelmetItemMixin {
|
|
/**
|
|
* Activate helmet "if in water or lava" -> "if in water or bad air or lava"
|
|
*/
|
|
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"),
|
|
method = "breatheUnderwater(Lnet/minecraft/world/entity/LivingEntity;)V")
|
|
private static boolean redirectBreatheUnderwater(boolean original, LivingEntity entity) {
|
|
boolean oxygen = true;
|
|
oxygen &= !original;
|
|
oxygen &= !entity.isUnderWater();
|
|
oxygen &= CreateAirFabric.isOxygen(entity);
|
|
|
|
return !oxygen;
|
|
}
|
|
} |