From 362d93da33c327e5f99fb309e5acc2bc9b218221 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Sun, 24 Mar 2024 00:13:02 +0800 Subject: [PATCH] Fix mixin conflict with AoA (#1285) --- .../mixin/core/world/entity/LivingEntityMixin.java | 10 +++++----- .../entity/player/ServerPlayerMixin_NeoForge.java | 10 ---------- .../item/crafting/RecipeManagerMixin_NeoForge.java | 5 ++--- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java index 8016fe07b..ef77cb77c 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java @@ -1,7 +1,6 @@ package io.izzel.arclight.common.mixin.core.world.entity; import com.google.common.base.Function; -import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.datafixers.util.Either; @@ -95,6 +94,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; @SuppressWarnings({"ConstantConditions", "Guava"}) @Mixin(LivingEntity.class) @@ -456,16 +456,16 @@ public int getExpReward() { } } - @Redirect(method = "removeAllEffects", at = @At(value = "INVOKE", target = "Ljava/util/Collection;iterator()Ljava/util/Iterator;")) - private Iterator arclight$clearReason(Collection instance) { + @Redirect(method = "removeAllEffects", at = @At(value = "INVOKE", target = "Ljava/util/Map;values()Ljava/util/Collection;")) + private Collection arclight$clearReason(Map instance) { var cause = bridge$getEffectCause().orElse(EntityPotionEffectEvent.Cause.UNKNOWN); - return Iterators.filter(instance.iterator(), effect -> { + return instance.values().stream().filter(effect -> { EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); if (event.isCancelled()) { return false; } return true; - }); + }).collect(Collectors.toList()); } /** diff --git a/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/entity/player/ServerPlayerMixin_NeoForge.java b/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/entity/player/ServerPlayerMixin_NeoForge.java index c8744d1ba..df0360461 100644 --- a/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/entity/player/ServerPlayerMixin_NeoForge.java +++ b/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/entity/player/ServerPlayerMixin_NeoForge.java @@ -95,16 +95,6 @@ public abstract class ServerPlayerMixin_NeoForge extends PlayerMixin_NeoForge im } } - /** - * @author IzzelAliz - * @reason - */ - @Override - @Nullable - public Entity changeDimension(ServerLevel arg) { - return this.changeDimension(arg, arg.getPortalForcer()); - } - /** * @author IzzelAliz * @reason diff --git a/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/item/crafting/RecipeManagerMixin_NeoForge.java b/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/item/crafting/RecipeManagerMixin_NeoForge.java index e944621c7..2ce909e60 100644 --- a/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/item/crafting/RecipeManagerMixin_NeoForge.java +++ b/arclight-neoforge/src/main/java/io/izzel/arclight/neoforge/mixin/core/world/item/crafting/RecipeManagerMixin_NeoForge.java @@ -4,9 +4,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.mojang.serialization.DynamicOps; -import com.mojang.serialization.JsonOps; import io.izzel.arclight.common.bridge.core.world.item.crafting.RecipeManagerBridge; -import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; import net.minecraft.util.GsonHelper; @@ -31,6 +29,7 @@ public RecipeManagerMixin_NeoForge(Gson gson, String string) { @Override public RecipeHolder bridge$platform$loadRecipe(ResourceLocation key, JsonElement element) { - return fromJson(key, GsonHelper.convertToJsonObject(element, "top element"), ConditionalOps.create(RegistryOps.create(JsonOps.INSTANCE, this.registryAccess), this.conditionContext)).orElse(null); + ConditionalOps ops = this.makeConditionalOps(); + return fromJson(key, GsonHelper.convertToJsonObject(element, "top element"), ops).orElse(null); } }