Skip to content

Commit

Permalink
- 简化 StellarPooledNBT 的结构以提高 NBTTagPrimitivePool 功能的兼容性。
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Nov 20, 2024
1 parent 2f2d758 commit d4c4967
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;

@Mixin(NBTTagCompound.class)
public class MixinNBTTagCompound {
public class MixinNBTTagCompound implements StellarPooledNBT {

@Final
@Shadow
Expand Down Expand Up @@ -96,4 +96,10 @@ public void setDouble(String key, double value) {
this.tagMap.put(key, NBTTagPrimitivePool.getTagDouble(value));
}

@SuppressWarnings("RedundantCast")
@Override
public Object stellar_core$getPooledNBT() {
return (Object) this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@SuppressWarnings("MethodMayBeStatic")
@Mixin(NBTTagList.class)
public class MixinNBTTagList {
public class MixinNBTTagList implements StellarPooledNBT {

/**
* @author Kasumi_Nova
Expand All @@ -32,4 +32,10 @@ private Object redirectSet(final List<Object> instance, final int i, final Objec
return instance.set(i, StellarPooledNBT.stellar_core$getPooledNBT((NBTBase) element));
}

@SuppressWarnings("RedundantCast")
@Override
public Object stellar_core$getPooledNBT() {
return (Object) this;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package github.kasuminova.stellarcore.mixin.minecraft.nbtpool;

import github.kasuminova.stellarcore.mixin.util.StellarPooledNBT;
import net.minecraft.nbt.NBTTagString;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -10,7 +11,7 @@
import javax.annotation.Nonnull;

@Mixin(NBTTagString.class)
public class MixinNBTTagString {
public class MixinNBTTagString implements StellarPooledNBT {

/**
* @author Kasumi_Nova
Expand All @@ -22,6 +23,11 @@ public NBTTagString copy() {
return (NBTTagString) (Object) this;
}

@Override
public Object stellar_core$getPooledNBT() {
return copy();
}

/**
* @author Kasumi_Nova
* @reason Constant Tag.
Expand Down

0 comments on commit d4c4967

Please # to comment.