mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-07 22:16: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;
|
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;
|
public final class OxygenUtils {
|
||||||
import net.minecraft.entity.LivingEntity;
|
public static OxygenApi API = entity -> false;
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public interface OxygenUtils {
|
public interface OxygenApi {
|
||||||
boolean MOD_LOADED = FabricLoader.getInstance().isModLoaded("ad_astra");
|
boolean hasOxygen(Entity entity);
|
||||||
|
|
||||||
static boolean entityHasOxygen(World world, LivingEntity entity) {
|
|
||||||
if (MOD_LOADED) {
|
|
||||||
return MixinOxygenUtils.entityHasOxygen(world, entity);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
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()))
|
|| 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;
|
return FlightType.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,30 @@
|
||||||
package com.minelittlepony.unicopia.mixin.ad_astra;
|
package com.minelittlepony.unicopia.mixin.ad_astra;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Dynamic;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Pseudo;
|
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 com.minelittlepony.unicopia.compat.ad_astra.OxygenUtils;
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
@Pseudo
|
@Pseudo
|
||||||
@Mixin(
|
@Mixin(
|
||||||
targets = { "earth.terrarium.ad_astra.common.util.OxygenUtils" },
|
targets = { "earth.terrarium.adastra.api.systems.OxygenApi" },
|
||||||
remap = false
|
remap = false
|
||||||
)
|
)
|
||||||
public interface MixinOxygenUtils {
|
public interface MixinOxygenUtils extends OxygenUtils.OxygenApi {
|
||||||
@Invoker("entityHasOxygen")
|
@Accessor("API")
|
||||||
static boolean entityHasOxygen(World world, LivingEntity entity) {
|
@Coerce
|
||||||
return true;
|
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