From 66a29c05b087c8904b4392e5dde4c70aada4810b Mon Sep 17 00:00:00 2001 From: 2No2Name <2No2Name@web.de> Date: Mon, 6 Jul 2020 13:30:59 +0200 Subject: [PATCH] fix: TagImplMixin breaks hotswap because its target does not exist --- .../{TagImplMixin.java => SetTagMixin.java} | 24 +++++++++---------- src/main/resources/lithium.mixins.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) rename src/main/java/me/jellysquid/mods/lithium/mixin/tag/{TagImplMixin.java => SetTagMixin.java} (65%) diff --git a/src/main/java/me/jellysquid/mods/lithium/mixin/tag/TagImplMixin.java b/src/main/java/me/jellysquid/mods/lithium/mixin/tag/SetTagMixin.java similarity index 65% rename from src/main/java/me/jellysquid/mods/lithium/mixin/tag/TagImplMixin.java rename to src/main/java/me/jellysquid/mods/lithium/mixin/tag/SetTagMixin.java index b530e2c8f..0faba49c7 100644 --- a/src/main/java/me/jellysquid/mods/lithium/mixin/tag/TagImplMixin.java +++ b/src/main/java/me/jellysquid/mods/lithium/mixin/tag/SetTagMixin.java @@ -3,8 +3,11 @@ import com.google.common.collect.ImmutableList; import it.unimi.dsi.fastutil.objects.ReferenceArraySet; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; +import net.minecraft.tag.SetTag; import net.minecraft.tag.Tag; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,12 +15,10 @@ import java.util.Set; -@Mixin(targets = "net/minecraft/tag/Tag$1") -public abstract class TagImplMixin implements Tag { - // Synthetic field -- plugin cannot see it - @SuppressWarnings("ShadowTarget") - @Shadow(remap = false) - private Set field_23686; +@Mixin(SetTag.class) +public abstract class SetTagMixin implements Tag { + @Shadow @Final @Mutable + private Set field_25594; /** * If the number of elements in a tag is very small (<=3), it can be significantly faster to use simple linear scanning @@ -29,15 +30,14 @@ public abstract class TagImplMixin implements Tag { * @author JellySquid */ // Plugin has trouble seeing this, but it exists - @SuppressWarnings("UnresolvedMixinReference") - @Inject(method = "(Ljava/util/Set;Lcom/google/common/collect/ImmutableList;)V", at = @At("RETURN")) - private void init(Set set, ImmutableList list, CallbackInfo ci) { + @Inject(method = "(Ljava/util/Set;Ljava/lang/Class;)V", at = @At("RETURN")) + private void init(Set set, Class var2, CallbackInfo ci) { // Reference equality is safe for tag values // Use linear-scanning when the number of items in the tag is small - if (this.field_23686.size() <= 3) { - this.field_23686 = new ReferenceArraySet<>(this.field_23686); + if (this.field_25594.size() <= 3) { + this.field_25594 = new ReferenceArraySet<>(this.field_25594); } else { - this.field_23686 = new ReferenceOpenHashSet<>(this.field_23686); + this.field_25594 = new ReferenceOpenHashSet<>(this.field_25594); } } } diff --git a/src/main/resources/lithium.mixins.json b/src/main/resources/lithium.mixins.json index d0561b903..d3dca017c 100644 --- a/src/main/resources/lithium.mixins.json +++ b/src/main/resources/lithium.mixins.json @@ -76,7 +76,7 @@ "shapes.shape_merging.VoxelShapesMixin", "shapes.specialized_shapes.VoxelShapeMixin", "shapes.specialized_shapes.VoxelShapesMixin", - "tag.TagImplMixin", + "tag.SetTagMixin", "world.chunk_access.ChunkHolderMixin", "world.chunk_access.ServerChunkManagerMixin", "world.chunk_access.WorldMixin",