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;
|
||||
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.simibubi.create.content.equipment.armor.DivingHelmetItem;
|
||||
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"
|
||||
*/
|
||||
@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")
|
||||
private static boolean redirectBreatheUnderwater(LivingEntity entity, TagKey<Fluid> fluidTagKey) {
|
||||
private static boolean redirectBreatheUnderwater(boolean original, LivingEntity entity) {
|
||||
boolean oxygen = true;
|
||||
oxygen &= !entity.isEyeInFluid(fluidTagKey);
|
||||
oxygen &= !original;
|
||||
oxygen &= !entity.isUnderWater();
|
||||
oxygen &= CreateAirFabric.isOxygen(entity);
|
||||
|
||||
|
@ -1,43 +1,41 @@
|
||||
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.BacktankUtil;
|
||||
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.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.LivingEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(OxygenApiImpl.class)
|
||||
public abstract class EntityOxygenSystemMixin {
|
||||
/**
|
||||
* 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")
|
||||
private boolean redirectHasOxygen(Entity entity) {
|
||||
if (!(entity instanceof LivingEntity livingEntity)) return SpaceSuitItem.hasOxygen(entity);
|
||||
private boolean redirectHasOxygen(boolean original, ServerLevel level, LivingEntity entity) {
|
||||
boolean createOxygen = true;
|
||||
createOxygen &= !DivingHelmetItem.getWornItem(livingEntity).isEmpty();
|
||||
createOxygen &= !BacktankUtil.getAllWithAir(livingEntity).isEmpty();
|
||||
return SpaceSuitItem.hasOxygen(livingEntity) || createOxygen;
|
||||
createOxygen &= !DivingHelmetItem.getWornItem(entity).isEmpty();
|
||||
createOxygen &= !BacktankUtil.getAllWithAir(entity).isEmpty();
|
||||
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")
|
||||
private boolean redirectHasFullSet(LivingEntity entity) {
|
||||
private boolean redirectHasFullSet(boolean original, ServerLevel level, LivingEntity entity) {
|
||||
boolean createArmor = true;
|
||||
createArmor &= entity.getItemBySlot(EquipmentSlot.HEAD).getItem() instanceof DivingHelmetItem;
|
||||
createArmor &= entity.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof BacktankItem;
|
||||
createArmor &= entity.getItemBySlot(EquipmentSlot.LEGS).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;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import earth.terrarium.adastra.common.items.armor.NetheriteSpaceSuitItem;
|
||||
import earth.terrarium.adastra.common.tags.ModItemTags;
|
||||
import earth.terrarium.adastra.common.systems.TemperatureApiImpl;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
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(TemperatureApiImpl.class)
|
||||
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")
|
||||
private void redirectTemperatureTick(TemperatureApiImpl instance, LivingEntity entity) {
|
||||
private boolean redirectTemperatureTick(boolean original, ServerLevel level, LivingEntity entity) {
|
||||
boolean createNetherite = true;
|
||||
createNetherite &= entity.getItemBySlot(EquipmentSlot.HEAD).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().isFireResistant();
|
||||
|
||||
if(!createNetherite) {
|
||||
entity.hurt(entity.damageSources().onFire(), 6);
|
||||
entity.setSecondsOnFire(10);
|
||||
}
|
||||
return original && !createNetherite;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package ru.bitheaven.createairfabric.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.simibubi.create.content.equipment.armor.RemainingAirOverlay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import ru.bitheaven.createairfabric.CreateAirFabric;
|
||||
|
||||
@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"
|
||||
*/
|
||||
@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")
|
||||
private static boolean redirectRender(LocalPlayer player, TagKey<Fluid> fluidTagKey) {
|
||||
return player.isEyeInFluid(fluidTagKey) || !CreateAirFabric.isOxygen(player);
|
||||
private static boolean redirectRender(boolean original) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
LocalPlayer player = mc.player;
|
||||
return original || !CreateAirFabric.isOxygen(player);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user