mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-20 15:39:32 +00:00
Add SparklyPower's LegacyNBTRemapper
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
--- a/ca/spottedleaf/dataconverter/minecraft/converters/itemstack/ConverterItemStackToDataComponents.java
|
||||||
|
+++ b/ca/spottedleaf/dataconverter/minecraft/converters/itemstack/ConverterItemStackToDataComponents.java
|
||||||
|
@@ -1220,6 +_,7 @@
|
||||||
|
ret.setString("id", this.id);
|
||||||
|
ret.setInt("count", this.count);
|
||||||
|
if (!this.tag.isEmpty()) {
|
||||||
|
+ net.sparklypower.sparklypaper.LegacyNBTRemapper.INSTANCE.remap(this.tag); // SparklyPaper - Remap SparklyPower hacky legacy NBT tags
|
||||||
|
this.components.setMap("minecraft:custom_data", this.tag);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/level/ServerEntity.java
|
--- a/net/minecraft/server/level/ServerEntity.java
|
||||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||||
@@ -205,6 +_,7 @@
|
@@ -209,6 +_,7 @@
|
||||||
|
|
||||||
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
||||||
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
||||||
if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
||||||
this.lastSentMovement = deltaMovement;
|
this.lastSentMovement = deltaMovement;
|
||||||
@@ -222,6 +_,7 @@
|
@@ -226,6 +_,7 @@
|
||||||
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/server/level/ServerLevel.java
|
--- a/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -562,6 +_,12 @@
|
@@ -565,6 +_,12 @@
|
||||||
}
|
}
|
||||||
// Paper end - chunk tick iteration
|
// Paper end - chunk tick iteration
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/entity/Display.java
|
--- a/net/minecraft/world/entity/Display.java
|
||||||
+++ b/net/minecraft/world/entity/Display.java
|
+++ b/net/minecraft/world/entity/Display.java
|
||||||
@@ -681,7 +_,7 @@
|
@@ -677,7 +_,7 @@
|
||||||
private static final byte INITIAL_TEXT_OPACITY = -1;
|
private static final byte INITIAL_TEXT_OPACITY = -1;
|
||||||
public static final int INITIAL_BACKGROUND = 1073741824;
|
public static final int INITIAL_BACKGROUND = 1073741824;
|
||||||
private static final int INITIAL_LINE_WIDTH = 200;
|
private static final int INITIAL_LINE_WIDTH = 200;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/entity/player/Player.java
|
--- a/net/minecraft/world/entity/player/Player.java
|
||||||
+++ b/net/minecraft/world/entity/player/Player.java
|
+++ b/net/minecraft/world/entity/player/Player.java
|
||||||
@@ -2127,6 +_,12 @@
|
@@ -2146,6 +_,12 @@
|
||||||
if (!(shootable.getItem() instanceof ProjectileWeaponItem)) {
|
if (!(shootable.getItem() instanceof ProjectileWeaponItem)) {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
--- a/net/minecraft/world/level/block/Blocks.java
|
--- a/net/minecraft/world/level/block/Blocks.java
|
||||||
+++ b/net/minecraft/world/level/block/Blocks.java
|
+++ b/net/minecraft/world/level/block/Blocks.java
|
||||||
@@ -6899,6 +_,52 @@
|
@@ -6887,6 +_,52 @@
|
||||||
.sound(SoundType.SWEET_BERRY_BUSH)
|
.sound(SoundType.SWEET_BERRY_BUSH)
|
||||||
.pushReaction(PushReaction.DESTROY)
|
.pushReaction(PushReaction.DESTROY)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package net.sparklypower.sparklypaper
|
||||||
|
|
||||||
|
import ca.spottedleaf.dataconverter.types.MapType
|
||||||
|
|
||||||
|
object LegacyNBTRemapper {
|
||||||
|
/**
|
||||||
|
* Remaps hacky direct NBT storage used in SparklyPower to proper PersistentDataContainer data
|
||||||
|
*/
|
||||||
|
fun remap(tag: MapType) {
|
||||||
|
val perfectDreamsMap = tag.getMap("PerfectDreams")
|
||||||
|
|
||||||
|
if (perfectDreamsMap != null) {
|
||||||
|
val publicBukkitValuesMap = tag.getOrCreateMap("PublicBukkitValues")
|
||||||
|
|
||||||
|
// The "setBoolean" functions do set bytes behind the scenes, just like how we do the things in SparklyPower
|
||||||
|
perfectDreamsMap.getStringAndRemove("isJetpack")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_jetpack", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("disallowCrafting")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:disallow_crafting", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("poop")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_poop", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("renamedBySeuZe")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_renamed_by_seu_ze", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("isMonsterPickaxe")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_monster_tool", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("itemOwner")?.let {
|
||||||
|
publicBukkitValuesMap.setString("sparklypower:item_owner", it)
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("DreamFusca")?.let {
|
||||||
|
publicBukkitValuesMap.setString("sparklypower:fusca_info", it)
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("isFusca")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_fusca", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("fancyLeatherArmor")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_fancy_leather_armor", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("caixaSecretaLevel")?.let {
|
||||||
|
publicBukkitValuesMap.setInt("sparklypower:caixa_secreta_level", it.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("caixaSecretaWorld")?.let {
|
||||||
|
publicBukkitValuesMap.setString("sparklypower:caixa_secreta_world", it)
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("isMoveSpawners")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_move_spawners_tool", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("spawnerType")?.let {
|
||||||
|
publicBukkitValuesMap.setString("sparklypower:spawner_type", it)
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("isMochila")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_mochila", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("mochilaId")?.let {
|
||||||
|
publicBukkitValuesMap.setLong("sparklypower:mochila_id", it.toLong())
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("customMapOwner")?.let {
|
||||||
|
publicBukkitValuesMap.setString("sparklypower:map_custom_owner", it)
|
||||||
|
}
|
||||||
|
|
||||||
|
perfectDreamsMap.getStringAndRemove("quickTeleport")?.let {
|
||||||
|
publicBukkitValuesMap.setBoolean("sparklypower:is_quick_resources_teleport", it.toBoolean())
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it is empty, then it means that we have migrated everything and we can remove the old PerfectDreams tag, yay!
|
||||||
|
if (perfectDreamsMap.isEmpty)
|
||||||
|
tag.remove("PerfectDreams")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun MapType.getStringAndRemove(key: String): String? {
|
||||||
|
val v = getString(key)
|
||||||
|
remove(key)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user