Yatopia/patches/api/0006-Add-NBT-API-as-first-class-lib.patch
budgidiere ff560e687c
[WIP] Better Patch System (#18)
* Update build.yml

* Remove 3rd party patches

* Add Upsteam Submodules

* Fix patches

* ?

* Fix patches

* Add Fast Init script

* Lots of stuff

also it's broke

* more broken

* fixes

* mor stuff

* gfhfgh

hg

* fix patch

* fix up script

* update submodule

* add papercut

* update tuinity

* update gitmodules

* fix var name

* fix more var stuff

* some how it's not deleting shit anymore

* should now use the branch it just made

why are we doing this again?

* now it does thing thing

* return previous so YAPFA can use it

* ok now it really does the thing

* for REAL it does the thing

* don't do the thing because it causes too many problems

* fix api

* work

* use better patching for YAPFA patches

* fix better patching

* more fixes

* new patches stuff

* remove old 3rd parry patches add removed akarin patches

* make new branch for making patches

* hopefully build patches correctly

* fix gitignore and add config patches

* remove papercut files

* fix some weirdness

* fix bug

* time to do some fixin' 👀

* New Patch System Rebased Patches

* fix full build

* exit 1

* fix

* Remove patch

* Hopefully fix compile errors

* fixes

* this might work

* don't use rej for our patches

* tmp disable cache

* some times case sensitivity is dumb

* my sanity is at an all time low :)

* dfg

* readd cahce

* fix?

* Update Upstream

* fix perms

* fix

* fix api

* Redo API

* rm folders

* fix villager brain patch

* emc explosion pref

* fixed aikar's shit

* betterfix

* fix lagggg

* Origami

* Origami Fixes

* Update readme

* test async path finding

* WIP Async Path Finding

* WIP fix async path finding

* same as bellow

* same

* update to newer funcs

* fix newer funcs

* fix author

* Updates, Fixes, and new patches

* fixes

* possibly async flying path finding

* minor asnyc pathfinding fix

* test remove non asnyc path finder

* WIP make all path finding async

* Rename everything

* Exec flag

* Rebuild hashes

* remove dupe patch

* fix?

* Fix packages, redirect config

* old nav class is now async and back

* add getchatcolor.getbyid and handle patches with a . in them better

Co-authored-by: tr7zw <tr7zw@live.de>
Co-authored-by: Unknown <unknown@example.com>
Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
2020-08-03 11:48:42 -05:00

141 lines
4.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bud Gidiere <sgidiere@gmail.com>
Date: Sat, 1 Aug 2020 15:55:15 -0500
Subject: [PATCH] Add NBT API as first class lib
diff --git a/pom.xml b/pom.xml
index 3a49ca4b8af1c9715cda8efde3d09efef92354fe..9338a6a97d9ac2ce010928ffe330fc791030c0f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,11 @@
<id>mojang</id>
<url>https://libraries.minecraft.net/</url>
</repository>
+ <!-- CodeMC -->
+ <repository>
+ <id>codemc-repo</id>
+ <url>https://repo.codemc.org/repository/maven-public/</url>
+ </repository>
</repositories>
<pluginRepositories>
@@ -157,6 +162,11 @@
<artifactId>asm-commons</artifactId>
<version>8.0.1</version>
</dependency>
+ <dependency>
+ <groupId>de.tr7zw</groupId>
+ <artifactId>item-nbt-api</artifactId>
+ <version>2.4.1</version>
+ </dependency>
</dependencies>
<build>
@@ -232,6 +242,12 @@
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<!-- when downloading via Maven we can pull depends individually -->
<shadedArtifactAttached>true</shadedArtifactAttached>
+ <relocations>
+ <relocation>
+ <pattern>de.tr7zw.changeme.nbtapi</pattern>
+ <shadedPattern>de.tr7zw.nbtapi</shadedPattern>
+ </relocation>
+ </relocations>
</configuration>
</plugin>
<plugin>
diff --git a/src/main/java/org/bukkit/block/TileState.java b/src/main/java/org/bukkit/block/TileState.java
index 3b10fcc13893403b29f0260b8605144679e89b82..8e56171795cb9110fa10f5cd98083abc30e67b41 100644
--- a/src/main/java/org/bukkit/block/TileState.java
+++ b/src/main/java/org/bukkit/block/TileState.java
@@ -4,6 +4,8 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataHolder;
import org.jetbrains.annotations.NotNull;
+import de.tr7zw.changeme.nbtapi.NBTTileEntity;
+
/**
* Represents a block state that also hosts a tile entity at the given location.
*
@@ -36,4 +38,12 @@ public interface TileState extends BlockState, PersistentDataHolder {
@NotNull
@Override
PersistentDataContainer getPersistentDataContainer();
+
+ // Yatopia start
+
+ public default NBTTileEntity getNBT() {
+ return new NBTTileEntity(this);
+ }
+
+ // Yatopia end
}
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 7808ade92ccd3553056c57cdf77464fb8bdf9312..7ee13b985d1e408593a84825531e457e9fbcc4b0 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -23,6 +23,9 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import de.tr7zw.changeme.nbtapi.NBTCompound;
+import de.tr7zw.changeme.nbtapi.NBTEntity;
+
/**
* Represents a base entity in the world
*/
@@ -695,4 +698,16 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
*/
public boolean isInLava();
// Paper end
+
+ // Yatopia start
+
+ public default NBTEntity getNBT() {
+ return new NBTEntity(this);
+ }
+
+ public default NBTCompound getNBTC() {
+ return getNBT().getPersistentDataContainer();
+ }
+
+ // Yatopia end
}
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index ccd81fca25233c2a9c2a8c3f4dda3053d7b2e723..802e6c620c831a7187fc52841c110c2934ab8d1b 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -1,6 +1,10 @@
package org.bukkit.inventory;
import com.google.common.collect.ImmutableMap;
+
+import de.tr7zw.changeme.nbtapi.NBTItem;
+import de.tr7zw.changeme.nbtapi.NBTType;
+
import java.util.LinkedHashMap;
import java.util.List; // Paper
import java.util.Map;
@@ -791,4 +795,20 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
return itemMeta.hasItemFlag(flag);
}
// Paper end
+
+ // Yatopia start
+
+ public NBTItem getNBT() {
+ return new NBTItem(this);
+ }
+
+ public void setNBT(NBTItem nbt) {
+ ItemStack nbtItem = nbt.getItem();
+ setType(nbtItem.getType());
+ setAmount(nbtItem.getAmount());
+ setData(nbtItem.getData());
+ setItemMeta(nbtItem.getItemMeta());
+ }
+
+ // Yatopia end
}