This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
117 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: 404Setup <153366651+404Setup@users.noreply.github.com> | ||
Date: Tue, 22 Oct 2024 11:16:12 +0800 | ||
Subject: [PATCH] List Utils | ||
|
||
|
||
diff --git a/src/main/java/one/tranic/vine/util/List.java b/src/main/java/one/tranic/vine/util/List.java | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..2f782f7bca06ded6000c697c0d937352e8b6c710 | ||
--- /dev/null | ||
+++ b/src/main/java/one/tranic/vine/util/List.java | ||
@@ -0,0 +1,28 @@ | ||
+package one.tranic.vine.util; | ||
+ | ||
+import com.google.common.collect.Iterators; | ||
+import org.jetbrains.annotations.Nullable; | ||
+ | ||
+import java.util.Collection; | ||
+ | ||
+import static com.google.common.base.Preconditions.checkNotNull; | ||
+ | ||
+public class List { | ||
+ public static <T extends @Nullable Object> java.util.List<T> newList() { | ||
+ return new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); | ||
+ } | ||
+ | ||
+ public static <T extends @Nullable Object> java.util.List<T> newList(Iterable<? extends T> elements) { | ||
+ checkNotNull(elements); | ||
+ if (elements instanceof Collection) { | ||
+ return newList((Collection<? extends T>) elements); | ||
+ } | ||
+ java.util.List<T> list = newList(); | ||
+ Iterators.addAll(list, elements.iterator()); | ||
+ return list; | ||
+ } | ||
+ | ||
+ public static <T extends @Nullable Object> java.util.List<T> newList(Collection<? extends T> c) { | ||
+ return new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(c); | ||
+ } | ||
+} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: 404Setup <153366651+404Setup@users.noreply.github.com> | ||
Date: Tue, 22 Oct 2024 10:21:19 +0800 | ||
Subject: [PATCH] Some nbt changes | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java | ||
index 4e005b7b062e3231f564d284887ea1c2783a4e7d..9d306ae46d4a5720561b1628f7440d6ef99e9f6c 100644 | ||
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java | ||
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java | ||
@@ -492,7 +492,7 @@ public class CompoundTag implements Tag { | ||
} | ||
|
||
protected CompoundTag shallowCopy() { | ||
- return new CompoundTag(new HashMap<>(this.tags)); | ||
+ return new CompoundTag(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(this.tags)); | ||
} | ||
|
||
@Override | ||
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java | ||
index 154bffd341e43be0a0fa710cfbed1a2094f249a3..3b77b59be0d09b77efc3ec3eb6f50c073bfcfc27 100644 | ||
--- a/src/main/java/net/minecraft/nbt/ListTag.java | ||
+++ b/src/main/java/net/minecraft/nbt/ListTag.java | ||
@@ -1,7 +1,6 @@ | ||
package net.minecraft.nbt; | ||
|
||
import com.google.common.collect.Iterables; | ||
-import com.google.common.collect.Lists; | ||
import java.io.DataInput; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
@@ -35,7 +34,7 @@ public class ListTag extends CollectionTag<Tag> { | ||
} else { | ||
tracker.accountBytes(4L, (long)i); | ||
TagType<?> tagType = TagTypes.getType(b); | ||
- List<Tag> list = Lists.newArrayListWithCapacity(i); | ||
+ List<Tag> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(i); | ||
|
||
for (int j = 0; j < i; j++) { | ||
list.add(tagType.load(input, tracker)); | ||
@@ -142,7 +141,7 @@ public class ListTag extends CollectionTag<Tag> { | ||
} | ||
|
||
public ListTag() { | ||
- this(Lists.newArrayList(), (byte)0); | ||
+ this(new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(), (byte)0); | ||
} | ||
|
||
@Override | ||
@@ -363,8 +362,8 @@ public class ListTag extends CollectionTag<Tag> { | ||
|
||
@Override | ||
public ListTag copy() { | ||
- Iterable<Tag> iterable = (Iterable<Tag>)(TagTypes.getType(this.type).isValue() ? this.list : Iterables.transform(this.list, Tag::copy)); | ||
- List<Tag> list = Lists.newArrayList(iterable); | ||
+ Iterable<Tag> iterable = TagTypes.getType(this.type).isValue() ? this.list : Iterables.transform(this.list, Tag::copy); | ||
+ List<Tag> list = one.tranic.vine.util.List.newList(iterable); | ||
return new ListTag(list, this.type); | ||
} | ||
|
||
diff --git a/src/main/java/net/minecraft/nbt/NbtOps.java b/src/main/java/net/minecraft/nbt/NbtOps.java | ||
index 576a92501660dad06f6a40bc5d6d878592be6044..fb3396ae8239eaf8a699fc2927e26153e185d385 100644 | ||
--- a/src/main/java/net/minecraft/nbt/NbtOps.java | ||
+++ b/src/main/java/net/minecraft/nbt/NbtOps.java | ||
@@ -127,7 +127,7 @@ public class NbtOps implements DynamicOps<Tag> { | ||
return DataResult.error(() -> "mergeToMap called with not a map: " + tag, tag); | ||
} else { | ||
CompoundTag compoundTag2 = tag instanceof CompoundTag compoundTag ? compoundTag.shallowCopy() : new CompoundTag(); | ||
- List<Tag> list = new ArrayList<>(); | ||
+ List<Tag> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); | ||
mapLike.entries().forEach(pair -> { | ||
Tag tagx = pair.getFirst(); | ||
if (!(tagx instanceof StringTag)) { | ||
@@ -145,7 +145,7 @@ public class NbtOps implements DynamicOps<Tag> { | ||
return DataResult.error(() -> "mergeToMap called with not a map: " + tag, tag); | ||
} else { | ||
CompoundTag compoundTag2 = tag instanceof CompoundTag compoundTag ? compoundTag.shallowCopy() : new CompoundTag(); | ||
- List<Tag> list = new ArrayList<>(); | ||
+ List<Tag> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); | ||
|
||
for (Entry<Tag, Tag> entry : map.entrySet()) { | ||
Tag tag2 = entry.getKey(); | ||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java | ||
index f88dd37783b3c155c23b547c360b8d3c16e030c0..a14a3e62258a77d6f135accacb90f46672980607 100644 | ||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java | ||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java | ||
@@ -306,7 +306,7 @@ public final class NbtUtils { | ||
break; | ||
case 10: | ||
CompoundTag compoundTag = (CompoundTag)nbt; | ||
- List<String> list = Lists.newArrayList(compoundTag.getAllKeys()); | ||
+ List<String> list = one.tranic.vine.util.List.newList(compoundTag.getAllKeys()); | ||
Collections.sort(list); | ||
indent(depth, stringBuilder).append('{'); | ||
if (stringBuilder.length() - stringBuilder.lastIndexOf("\n") > 2 * (depth + 1)) { |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.