Skip to content

Commit

Permalink
Some nbt changes
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Oct 22, 2024
1 parent daec2f4 commit 3759a1a
Show file tree
Hide file tree
Showing 117 changed files with 143 additions and 7 deletions.
15 changes: 8 additions & 7 deletions patches/server/0005-VineLogger.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ Subject: [PATCH] VineLogger

diff --git a/src/main/kotlin/one/tranic/vine/util/VineLogger.kt b/src/main/kotlin/one/tranic/vine/util/VineLogger.kt
new file mode 100644
index 0000000000000000000000000000000000000000..817eb350fc7cce5bed9b7afffc681b7f42d92e2f
index 0000000000000000000000000000000000000000..9c3a9a5c74d16b2cd650188c3d2a386d9e885da4
--- /dev/null
+++ b/src/main/kotlin/one/tranic/vine/util/VineLogger.kt
@@ -0,0 +1,53 @@
@@ -0,0 +1,54 @@
+package one.tranic.vine.util
+
+import net.minecraft.server.MinecraftServer
+import org.slf4j.Logger
+
+object VineLogger {
+ private val logger: org.slf4j.Logger = MinecraftServer.LOGGER
+ private val logger: Logger = MinecraftServer.LOGGER
+
+ fun get(): org.slf4j.Logger {
+ fun get(): Logger {
+ return logger
+ }
+
Expand All @@ -29,7 +30,7 @@ index 0000000000000000000000000000000000000000..817eb350fc7cce5bed9b7afffc681b7f
+ logger.info(msg, args)
+ }
+
+ fun info(msg: List<String>) {
+ fun info(msg: kotlin.collections.List<String>) {
+ for (str in msg) {
+ logger.info(str)
+ }
Expand All @@ -43,7 +44,7 @@ index 0000000000000000000000000000000000000000..817eb350fc7cce5bed9b7afffc681b7f
+ logger.warn(msg, args)
+ }
+
+ fun warn(msg: List<String>) {
+ fun warn(msg: kotlin.collections.List<String>) {
+ for (str in msg) {
+ logger.warn(str)
+ }
Expand All @@ -57,7 +58,7 @@ index 0000000000000000000000000000000000000000..817eb350fc7cce5bed9b7afffc681b7f
+ logger.error(msg, args)
+ }
+
+ fun error(msg: List<String>) {
+ fun error(msg: kotlin.collections.List<String>) {
+ for (str in msg) {
+ logger.error(str)
+ }
Expand Down
40 changes: 40 additions & 0 deletions patches/server/0007-List-Utils.patch
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.
95 changes: 95 additions & 0 deletions patches/server/0037-Some-nbt-changes.patch
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.

0 comments on commit 3759a1a

Please sign in to comment.