Skip to content

Commit

Permalink
- 简化 StellarPooledNBT 的结构以提高 NBTTagPrimitivePool 功能的兼容性。
Browse files Browse the repository at this point in the history
- 添加 remap = false
  • Loading branch information
KasumiNova committed Nov 15, 2024
1 parent d02e12f commit 2f2d758
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 63 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

// Project properties
group = "github.kasuminova.stellarcore"
version = "1.5.19"
version = "1.5.20"

// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package github.kasuminova.stellarcore.common.pool;

import github.kasuminova.stellarcore.common.util.StellarLog;
import github.kasuminova.stellarcore.mixin.util.StellarPooledNBT;
import net.minecraft.nbt.*;

import java.util.Arrays;
Expand Down Expand Up @@ -30,19 +29,10 @@ public class NBTTagPrimitivePool {
Arrays.setAll(TAG_LONGS, i -> new NBTTagLong (i - SHORT_OFFSET));
Arrays.setAll(TAG_FLOATS, i -> new NBTTagFloat (i - SHORT_OFFSET));
Arrays.setAll(TAG_DOUBLES, i -> new NBTTagDouble(i - SHORT_OFFSET));
Arrays.stream(TAG_BYTES) .forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
Arrays.stream(TAG_SHORTS) .forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
Arrays.stream(TAG_INTS) .forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
Arrays.stream(TAG_LONGS) .forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
Arrays.stream(TAG_FLOATS) .forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
Arrays.stream(TAG_DOUBLES).forEach(tag -> ((StellarPooledNBT) tag).stellar_core$setPooled(true));
StellarLog.LOG.info("[StellarCore-NBTTagPrimitivePool] PrimitiveType NBTTagPrimitivePool initialized, took {}ms.", System.currentTimeMillis() - start);
}

public static NBTTagByte getTagByte(final NBTTagByte tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
return TAG_BYTES[tag.getByte() + 128];
}

Expand All @@ -51,9 +41,6 @@ public static NBTTagByte getTagByte(final byte b) {
}

public static NBTTagShort getTagShort(final NBTTagShort tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
return TAG_SHORTS[tag.getShort() + SHORT_OFFSET];
}

Expand All @@ -62,9 +49,6 @@ public static NBTTagShort getTagShort(final short s) {
}

public static NBTTagInt getTagInt(final NBTTagInt tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
final int value = tag.getInt();
return value < MINIMUM || value > MAXIMUM
? tag
Expand All @@ -78,9 +62,6 @@ public static NBTTagInt getTagInt(final int i) {
}

public static NBTTagLong getTagLong(final NBTTagLong tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
final long value = tag.getLong();
return value < MINIMUM || value > MAXIMUM
? tag
Expand All @@ -94,9 +75,6 @@ public static NBTTagLong getTagLong(final long l) {
}

public static NBTTagFloat getTagFloat(final NBTTagFloat tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
final float value = tag.getFloat();
return isFloatInteger(value)
? value < MINIMUM || value > MAXIMUM ? tag : TAG_FLOATS[((int) value + SHORT_OFFSET)]
Expand All @@ -110,9 +88,6 @@ public static NBTTagFloat getTagFloat(final float f) {
}

public static NBTTagDouble getTagDouble(final NBTTagDouble tag) {
if (((StellarPooledNBT) tag).stellar_core$isPooled()) {
return tag;
}
final double value = tag.getDouble();
return isDoubleInteger(value)
? value < MINIMUM || value > MAXIMUM ? tag : TAG_DOUBLES[((int) value + SHORT_OFFSET)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class MixinTileRuneAltar extends TileSimpleInventory {
@Shadow(remap = false)
RecipeRuneAltar currentRecipe;

@Shadow
@Shadow(remap = false)
List<ItemStack> lastRecipe;

@Unique
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class MixinNBTTagByte implements StellarPooledNBT {
@Nonnull
@Overwrite
public NBTTagByte copy() {
return stellar_core$isPooled() ? (NBTTagByte) (Object) this : NBTTagPrimitivePool.getTagByte((NBTTagByte) (Object) this);
return NBTTagPrimitivePool.getTagByte((NBTTagByte) (Object) this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class MixinNBTTagShort implements StellarPooledNBT {
@Nonnull
@Overwrite
public NBTTagShort copy() {
return stellar_core$isPooled() ? (NBTTagShort) (Object) this : NBTTagPrimitivePool.getTagShort((NBTTagShort) (Object) this);
return NBTTagPrimitivePool.getTagShort((NBTTagShort) (Object) this);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,4 @@ public interface StellarPooledNBT {
*/
Object stellar_core$getPooledNBT();

boolean stellar_core$isPooled();

void stellar_core$setPooled(boolean pooled);

}

0 comments on commit 2f2d758

Please sign in to comment.