mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 03:26:44 +01:00
Update ad-astra integration
This commit is contained in:
parent
1922c02f5b
commit
095b10802f
3 changed files with 24 additions and 21 deletions
|
@ -1,18 +1,11 @@
|
|||
package com.minelittlepony.unicopia.compat.ad_astra;
|
||||
|
||||
import com.minelittlepony.unicopia.mixin.ad_astra.MixinOxygenUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.world.World;
|
||||
public final class OxygenUtils {
|
||||
public static OxygenApi API = entity -> false;
|
||||
|
||||
public interface OxygenUtils {
|
||||
boolean MOD_LOADED = FabricLoader.getInstance().isModLoaded("ad_astra");
|
||||
|
||||
static boolean entityHasOxygen(World world, LivingEntity entity) {
|
||||
if (MOD_LOADED) {
|
||||
return MixinOxygenUtils.entityHasOxygen(world, entity);
|
||||
}
|
||||
return false;
|
||||
public interface OxygenApi {
|
||||
boolean hasOxygen(Entity entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
|||
|
||||
if ((RegistryUtils.isIn(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE, UTags.HAS_NO_ATMOSPHERE)
|
||||
|| Unicopia.getConfig().dimensionsWithoutAtmosphere.get().contains(RegistryUtils.getId(entity.getWorld(), dimension, RegistryKeys.DIMENSION_TYPE).toString()))
|
||||
&& !OxygenUtils.entityHasOxygen(entity.getWorld(), entity)) {
|
||||
&& !OxygenUtils.API.hasOxygen(entity)) {
|
||||
return FlightType.NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
package com.minelittlepony.unicopia.mixin.ad_astra;
|
||||
|
||||
import org.spongepowered.asm.mixin.Dynamic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Coerce;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.world.World;
|
||||
import com.minelittlepony.unicopia.compat.ad_astra.OxygenUtils;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(
|
||||
targets = { "earth.terrarium.ad_astra.common.util.OxygenUtils" },
|
||||
targets = { "earth.terrarium.adastra.api.systems.OxygenApi" },
|
||||
remap = false
|
||||
)
|
||||
public interface MixinOxygenUtils {
|
||||
@Invoker("entityHasOxygen")
|
||||
static boolean entityHasOxygen(World world, LivingEntity entity) {
|
||||
return true;
|
||||
public interface MixinOxygenUtils extends OxygenUtils.OxygenApi {
|
||||
@Accessor("API")
|
||||
@Coerce
|
||||
static Object getAPI() {
|
||||
throw new AbstractMethodError("stub");
|
||||
}
|
||||
|
||||
@Dynamic("Compiler-generated class-init() method")
|
||||
@Inject(method = "<clinit>()V", at = @At("RETURN"), remap = false)
|
||||
private static void classInit() {
|
||||
OxygenUtils.API = (OxygenUtils.OxygenApi)getAPI();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue