Update Mixins from Redirect to Update Statement
This commit is contained in:
parent
824a2cf0a3
commit
fc5d12980f
@ -1,11 +1,8 @@
|
|||||||
package ru.bitheaven.createairfabric.mixin;
|
package ru.bitheaven.createairfabric.mixin;
|
||||||
|
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
||||||
import ru.bitheaven.createairfabric.CreateAirFabric;
|
import ru.bitheaven.createairfabric.CreateAirFabric;
|
||||||
@ -15,11 +12,11 @@ public abstract class DivingHelmetItemMixin {
|
|||||||
/**
|
/**
|
||||||
* Activate helmet "if in water or lava" -> "if in water or bad air or lava"
|
* Activate helmet "if in water or lava" -> "if in water or bad air or lava"
|
||||||
*/
|
*/
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"),
|
@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")
|
method = "breatheUnderwater(Lnet/minecraft/world/entity/LivingEntity;)V")
|
||||||
private static boolean redirectBreatheUnderwater(LivingEntity entity, TagKey<Fluid> fluidTagKey) {
|
private static boolean redirectBreatheUnderwater(boolean original, LivingEntity entity) {
|
||||||
boolean oxygen = true;
|
boolean oxygen = true;
|
||||||
oxygen &= !entity.isEyeInFluid(fluidTagKey);
|
oxygen &= !original;
|
||||||
oxygen &= !entity.isUnderWater();
|
oxygen &= !entity.isUnderWater();
|
||||||
oxygen &= CreateAirFabric.isOxygen(entity);
|
oxygen &= CreateAirFabric.isOxygen(entity);
|
||||||
|
|
||||||
|
@ -1,43 +1,41 @@
|
|||||||
package ru.bitheaven.createairfabric.mixin;
|
package ru.bitheaven.createairfabric.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
import com.simibubi.create.content.equipment.armor.BacktankItem;
|
import com.simibubi.create.content.equipment.armor.BacktankItem;
|
||||||
import com.simibubi.create.content.equipment.armor.BacktankUtil;
|
import com.simibubi.create.content.equipment.armor.BacktankUtil;
|
||||||
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
||||||
|
|
||||||
import earth.terrarium.adastra.common.items.armor.SpaceSuitItem;
|
|
||||||
import earth.terrarium.adastra.common.systems.OxygenApiImpl;
|
import earth.terrarium.adastra.common.systems.OxygenApiImpl;
|
||||||
import earth.terrarium.adastra.common.tags.ModItemTags;
|
import earth.terrarium.adastra.common.tags.ModItemTags;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(OxygenApiImpl.class)
|
@Mixin(OxygenApiImpl.class)
|
||||||
public abstract class EntityOxygenSystemMixin {
|
public abstract class EntityOxygenSystemMixin {
|
||||||
/**
|
/**
|
||||||
* Make air exists if Create Air
|
* Make air exists if Create Air
|
||||||
*/
|
*/
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/common/items/armor/SpaceSuitItem;hasOxygen(Lnet/minecraft/world/entity/Entity;)Z"),
|
@ModifyExpressionValue(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")
|
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
|
||||||
private boolean redirectHasOxygen(Entity entity) {
|
private boolean redirectHasOxygen(boolean original, ServerLevel level, LivingEntity entity) {
|
||||||
if (!(entity instanceof LivingEntity livingEntity)) return SpaceSuitItem.hasOxygen(entity);
|
|
||||||
boolean createOxygen = true;
|
boolean createOxygen = true;
|
||||||
createOxygen &= !DivingHelmetItem.getWornItem(livingEntity).isEmpty();
|
createOxygen &= !DivingHelmetItem.getWornItem(entity).isEmpty();
|
||||||
createOxygen &= !BacktankUtil.getAllWithAir(livingEntity).isEmpty();
|
createOxygen &= !BacktankUtil.getAllWithAir(entity).isEmpty();
|
||||||
return SpaceSuitItem.hasOxygen(livingEntity) || createOxygen;
|
return original || createOxygen;
|
||||||
}
|
}
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/common/items/armor/SpaceSuitItem;hasFullSet(Lnet/minecraft/world/entity/LivingEntity;)Z"),
|
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/common/items/armor/SpaceSuitItem;hasFullSet(Lnet/minecraft/world/entity/LivingEntity;)Z"),
|
||||||
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
|
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
|
||||||
private boolean redirectHasFullSet(LivingEntity entity) {
|
private boolean redirectHasFullSet(boolean original, ServerLevel level, LivingEntity entity) {
|
||||||
boolean createArmor = true;
|
boolean createArmor = true;
|
||||||
createArmor &= entity.getItemBySlot(EquipmentSlot.HEAD).getItem() instanceof DivingHelmetItem;
|
createArmor &= entity.getItemBySlot(EquipmentSlot.HEAD).getItem() instanceof DivingHelmetItem;
|
||||||
createArmor &= entity.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof BacktankItem;
|
createArmor &= entity.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof BacktankItem;
|
||||||
createArmor &= entity.getItemBySlot(EquipmentSlot.LEGS).is(ModItemTags.SPACE_SUITS);
|
createArmor &= entity.getItemBySlot(EquipmentSlot.LEGS).is(ModItemTags.SPACE_SUITS);
|
||||||
createArmor &= entity.getItemBySlot(EquipmentSlot.FEET).is(ModItemTags.SPACE_SUITS);
|
createArmor &= entity.getItemBySlot(EquipmentSlot.FEET).is(ModItemTags.SPACE_SUITS);
|
||||||
|
|
||||||
return SpaceSuitItem.hasFullSet(entity) || createArmor;
|
return original || createArmor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package ru.bitheaven.createairfabric.mixin;
|
package ru.bitheaven.createairfabric.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
import earth.terrarium.adastra.common.items.armor.NetheriteSpaceSuitItem;
|
import earth.terrarium.adastra.common.items.armor.NetheriteSpaceSuitItem;
|
||||||
import earth.terrarium.adastra.common.tags.ModItemTags;
|
import earth.terrarium.adastra.common.tags.ModItemTags;
|
||||||
import earth.terrarium.adastra.common.systems.TemperatureApiImpl;
|
import earth.terrarium.adastra.common.systems.TemperatureApiImpl;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
|
|
||||||
@Mixin(TemperatureApiImpl.class)
|
@Mixin(TemperatureApiImpl.class)
|
||||||
public abstract class EntityTemperatureSystemMixin {
|
public abstract class EntityTemperatureSystemMixin {
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/common/systems/TemperatureApiImpl;burnEntity(Lnet/minecraft/world/entity/LivingEntity;)V"),
|
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Learth/terrarium/adastra/api/events/AdAstraEvents$HotTemperatureTickEvent;fire(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)Z"),
|
||||||
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
|
method = "entityTick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/LivingEntity;)V")
|
||||||
private void redirectTemperatureTick(TemperatureApiImpl instance, LivingEntity entity) {
|
private boolean redirectTemperatureTick(boolean original, ServerLevel level, LivingEntity entity) {
|
||||||
boolean createNetherite = true;
|
boolean createNetherite = true;
|
||||||
createNetherite &= entity.getItemBySlot(EquipmentSlot.HEAD).getItem().isFireResistant();
|
createNetherite &= entity.getItemBySlot(EquipmentSlot.HEAD).getItem().isFireResistant();
|
||||||
createNetherite &= entity.getItemBySlot(EquipmentSlot.CHEST).getItem().isFireResistant();
|
createNetherite &= entity.getItemBySlot(EquipmentSlot.CHEST).getItem().isFireResistant();
|
||||||
@ -24,9 +25,6 @@ public abstract class EntityTemperatureSystemMixin {
|
|||||||
|| entity.getItemBySlot(EquipmentSlot.FEET).getItem() instanceof NetheriteSpaceSuitItem
|
|| entity.getItemBySlot(EquipmentSlot.FEET).getItem() instanceof NetheriteSpaceSuitItem
|
||||||
|| entity.getItemBySlot(EquipmentSlot.FEET).getItem().isFireResistant();
|
|| entity.getItemBySlot(EquipmentSlot.FEET).getItem().isFireResistant();
|
||||||
|
|
||||||
if(!createNetherite) {
|
return original && !createNetherite;
|
||||||
entity.hurt(entity.damageSources().onFire(), 6);
|
|
||||||
entity.setSecondsOnFire(10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package ru.bitheaven.createairfabric.mixin;
|
package ru.bitheaven.createairfabric.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
import com.simibubi.create.content.equipment.armor.RemainingAirOverlay;
|
import com.simibubi.create.content.equipment.armor.RemainingAirOverlay;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.tags.TagKey;
|
|
||||||
import net.minecraft.world.level.material.Fluid;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import ru.bitheaven.createairfabric.CreateAirFabric;
|
import ru.bitheaven.createairfabric.CreateAirFabric;
|
||||||
|
|
||||||
@Mixin(RemainingAirOverlay.class)
|
@Mixin(RemainingAirOverlay.class)
|
||||||
@ -14,9 +13,11 @@ public class RemainingAirOverlayMixin {
|
|||||||
/**
|
/**
|
||||||
* Activate UI "if in water or lava" -> "if in water or bad air or lava"
|
* Activate UI "if in water or lava" -> "if in water or bad air or lava"
|
||||||
*/
|
*/
|
||||||
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"),
|
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isEyeInFluid(Lnet/minecraft/tags/TagKey;)Z"),
|
||||||
method = "render(Lnet/minecraft/client/gui/GuiGraphics;II)V")
|
method = "render(Lnet/minecraft/client/gui/GuiGraphics;II)V")
|
||||||
private static boolean redirectRender(LocalPlayer player, TagKey<Fluid> fluidTagKey) {
|
private static boolean redirectRender(boolean original) {
|
||||||
return player.isEyeInFluid(fluidTagKey) || !CreateAirFabric.isOxygen(player);
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
LocalPlayer player = mc.player;
|
||||||
|
return original || !CreateAirFabric.isOxygen(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user