mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Port new changes
This commit is contained in:
parent
ee4414f149
commit
6748c71ef1
1 changed files with 4 additions and 4 deletions
|
@ -5,8 +5,8 @@ import com.simibubi.create.foundation.mixin.accessor.NbtAccounterAccessor;
|
|||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtAccounter;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
|
||||
public class ContraptionPickupLimiting {
|
||||
|
@ -36,17 +36,17 @@ public class ContraptionPickupLimiting {
|
|||
/**
|
||||
* @return true if the given NBT is too large for a contraption to be picked up with a wrench.
|
||||
*/
|
||||
public static boolean isTooLargeForPickup(CompoundTag data) {
|
||||
public static boolean isTooLargeForPickup(Tag data) {
|
||||
return nbtSize(data) > LIMIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size of the given NBT when read by the client according to {@link NbtAccounter}
|
||||
*/
|
||||
private static long nbtSize(CompoundTag data) {
|
||||
private static long nbtSize(Tag data) {
|
||||
FriendlyByteBuf test = new FriendlyByteBuf(Unpooled.buffer());
|
||||
test.writeNbt(data);
|
||||
NbtAccounter sizeTracker = new NbtAccounter(Long.MAX_VALUE);
|
||||
NbtAccounter sizeTracker = NbtAccounter.unlimitedHeap();
|
||||
test.readNbt(sizeTracker);
|
||||
long size = ((NbtAccounterAccessor) sizeTracker).create$getUsage();
|
||||
test.release();
|
||||
|
|
Loading…
Add table
Reference in a new issue