Fix? oxygen Ad Astra

This commit is contained in:
BitHeaven 2024-03-12 10:58:41 +05:00
parent 23667171ae
commit 3a3b3b11fa
1 changed files with 10 additions and 8 deletions

View File

@ -2,24 +2,26 @@ package ru.bitheaven.createairfabric.mixin;
import com.simibubi.create.content.equipment.armor.BacktankUtil;
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
import earth.terrarium.ad_astra.common.entity.system.EntityOxygenSystem;
import earth.terrarium.ad_astra.common.util.ModUtils;
import earth.terrarium.adastra.common.items.armor.SpaceSuitItem;
import earth.terrarium.adastra.common.systems.OxygenApiImpl;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(EntityOxygenSystem.class)
@Mixin(OxygenApiImpl.class)
public abstract class EntityOxygenSystemMixin {
/**
* Make air exists if Create Air
*/
@Redirect(at = @At(value = "INVOKE", target = "Learth/terrarium/ad_astra/common/util/ModUtils;armourIsOxygenated(Lnet/minecraft/world/entity/LivingEntity;)Z"),
method = "oxygenTick(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/server/level/ServerLevel;)V")
private static boolean redirectOxygenTick(LivingEntity entity) {
@Redirect(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/common/items/armor/SpaceSuitItem;hasOxygen(Lnet/minecraft/world/entity/Entity;)Z"),
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
private boolean redirectOxygenTick(Entity entity) {
boolean createOxygen = true;
createOxygen &= !DivingHelmetItem.getWornItem(entity).isEmpty();
createOxygen &= !BacktankUtil.getAllWithAir(entity).isEmpty();
return ModUtils.armourIsOxygenated(entity) || createOxygen;
createOxygen &= !BacktankUtil.getAllWithAir((LivingEntity) entity).isEmpty();
return SpaceSuitItem.hasOxygen(entity) || createOxygen;
}
}