mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-30 08:06:01 +00:00
I'm committing this right now. I don't know if it works but it compiles
This commit is contained in:
parent
243ebd8d3b
commit
4c0a4b8804
@ -5,10 +5,10 @@ Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d0764552e94 100644
|
||||
index b31ff9d237f593e58b42b453632aa2c2af74f986..67feb4e688d049e9f74f0deabb1ec583336a29be 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
@@ -175,7 +175,14 @@ public class HoverEvent {
|
||||
@@ -174,7 +174,14 @@ public class HoverEvent {
|
||||
} else {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(GsonHelper.getAsString(jsonObject, "type")));
|
||||
@ -24,7 +24,7 @@ index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d07
|
||||
Component component = Component.Serializer.fromJson(jsonObject.get("name"));
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
}
|
||||
@@ -187,7 +194,14 @@ public class HoverEvent {
|
||||
@@ -186,7 +193,14 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||
@ -38,5 +38,5 @@ index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d07
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
} catch (CommandSyntaxException | JsonSyntaxException var5) {
|
||||
} catch (Exception var5) {
|
||||
return null;
|
||||
|
@ -32,7 +32,7 @@ index 94dc68182ec5f6dc1294ad15523427836228086a..07075cea760562c901d4469a7f88271c
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index f57864ce919ef4721cfb5913c636fe8903ce4cc1..d80c7be5b153db4046d0b11c0116c6aa860ea48c 100644
|
||||
index 8a07d5d25086d7544757bb86181fbe2b5e743d29..ef50d9747f2a027e356b05ad8d94ffb2fd4a423e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -219,7 +219,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 03:01:29 -0600
|
||||
Subject: [PATCH] Fixes the Blank SkullOwner exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..4186b9558cbf6799e8491443b9ed5a2c9063ab7c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -6,6 +6,9 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
+// Scissors start
|
||||
+import org.apache.commons.lang3.StringUtils;
|
||||
+// Scissors end
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -47,7 +50,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
|
||||
- } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
|
||||
+ // Scissors start
|
||||
+ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) {
|
||||
+ // Scissors end
|
||||
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 06:10:22 -0600
|
||||
Subject: [PATCH] Fixes log spam caused by invalid entities in beehives
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
index 8484e80a70129fb0358d56efab6fd54798b54e6e..90fce5d2178672608f3ae97277cafe740a9ebead 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.protocol.game.DebugPackets;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
@@ -351,6 +352,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
|
||||
+
|
||||
+ // Scissors start - Do not allow invalid entities from being used for bees
|
||||
+ if (!nbttagcompound1.contains("id") || !ResourceLocation.isValidResourceLocation(nbttagcompound1.getString("id")) || EntityType.byString(nbttagcompound1.getString("id")).isEmpty()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Scissor end
|
||||
+
|
||||
BeehiveBlockEntity.BeeData tileentitybeehive_hivebee = new BeehiveBlockEntity.BeeData(nbttagcompound1.getCompound("EntityData"), nbttagcompound1.getInt("TicksInHive"), nbttagcompound1.getInt("MinOccupationTicks"));
|
||||
|
||||
this.stored.add(tileentitybeehive_hivebee);
|
19
patches/server/0005-fix-this-patch.patch
Normal file
19
patches/server/0005-fix-this-patch.patch
Normal file
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Tue, 19 Apr 2022 18:27:04 -0500
|
||||
Subject: [PATCH] fix this patch
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index ef50d9747f2a027e356b05ad8d94ffb2fd4a423e..574afb19e43ec5b17ae2fbee7db36e3164fe0a0b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -192,7 +192,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
if (!this.level.isClientSide && reason.shouldDestroy()) {
|
||||
- Containers.dropContents(this.level, (Entity) this, (Container) this);
|
||||
+ Containers.dropContents(this.level, this, this);
|
||||
}
|
||||
|
||||
super.remove(reason);
|
@ -5,10 +5,10 @@ Subject: [PATCH] ItemEntity - Check if items are air before calling setItem
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 063f3e4c67e6716c9a03dbe4b72eafd32e4f0d53..03b8cc0ae12f17cf3a1c57958cf10ca23750b92a 100644
|
||||
index f7d29950644a5cf12da0d31246d9f5fcbcc201bb..45866c9905cc607c58c398e675fe879e6e249398 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -377,11 +377,14 @@ public class ItemEntity extends Entity {
|
||||
@@ -378,11 +378,14 @@ public class ItemEntity extends Entity {
|
||||
|
||||
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
||||
|
@ -1,29 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 07:47:20 -0600
|
||||
Subject: [PATCH] Removes useless spammy error logging
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index c88ab49f60857d5687facc8523f9edc4d652c81b..2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -1758,7 +1758,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
try {
|
||||
blockParser = blockParser.parse(false);
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
- e.printStackTrace();
|
||||
+ // Scissors - Don't log errors thrown by Brigadier when an error is thrown
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1782,8 +1782,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
resource = CraftNamespacedKey.fromMinecraft(key);
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
- org.bukkit.Bukkit.getLogger().warning("Namespaced resource does not validate: " + key.toString());
|
||||
- ex.printStackTrace();
|
||||
+ // Scissors - Don't log errors thrown by invalid namespaces when an error is thrown
|
||||
}
|
||||
|
||||
return resource;
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
index bb5319afd112f1013445e29e9fcad137d4c581f9..1cd62752e675b91fdcc21733509c95d5bd97625a 100644
|
||||
index b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd222d0c178 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
@@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item {
|
@ -1,25 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 08:14:44 -0600
|
||||
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities
|
||||
with content in them
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index d80c7be5b153db4046d0b11c0116c6aa860ea48c..dfbae9ca58722c0aeb6cb9888643016d4cb36f63 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -192,7 +192,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
if (!this.level.isClientSide && reason.shouldDestroy()) {
|
||||
- Containers.dropContents(this.level, this, this);
|
||||
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
|
||||
+ try {
|
||||
+ Containers.dropContents(this.level, this, this);
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
super.remove(reason);
|
@ -5,7 +5,7 @@ Subject: [PATCH] Validate BlockState and SoundEvent values
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index dca8853944832e8fc5a291aa6b46d84b24181ea7..24f009fa3b84323b4c43e0ed15c224d16a7ede81 100644
|
||||
index 9865f9352ecac8175070187c2f67fedddb588864..fe87de42bc099ce41038f7f49ded9a12898e32eb 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -230,7 +230,7 @@ public final class NbtUtils {
|
||||
@ -18,10 +18,10 @@ index dca8853944832e8fc5a291aa6b46d84b24181ea7..24f009fa3b84323b4c43e0ed15c224d1
|
||||
if (compound.contains("Properties", 10)) {
|
||||
CompoundTag compoundTag = compound.getCompound("Properties");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index 52e4948fd1657fa1776ac6b0142e8c21e7567976..a811b97021e2eed6efc592bc33602a270feb75a0 100644
|
||||
index 53d0024daf6963ac4dab575666b0d6a74a39a958..ce13ba13c30428558391defbb09a49429dd10422 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -536,7 +536,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
@@ -549,7 +549,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
this.setCritArrow(nbt.getBoolean("crit"));
|
||||
this.setPierceLevel(nbt.getByte("PierceLevel"));
|
||||
if (nbt.contains("SoundEvent", 8)) {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Even more ResourceLocation validation and log spam fixes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
index 02172fdcf587904258387d309938fb379a300524..3c60094119a2b51d5fbab6c559c43293913f6204 100644
|
||||
index 7e1885d9cc568a544e934cede32bff05c20b567a..2481c50d8eb58a003e30e2d957b877bce5123a3a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
@@ -420,7 +420,7 @@ public class AreaEffectCloud extends Entity {
|
||||
@ -60,7 +60,7 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf1
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
index 5a43e420f14fa52d71d41ff3694a179e7a1a5be3..488ccdeb867dcd3aaae4bce77da8b7a11d07eddc 100644
|
||||
index cf0be5ef01bddaabbfd11f54b2dacd68c68ad16a..b4b86d7448e6659b1d4e034ffcddd7be77dd977f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
@@ -67,8 +67,14 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
@ -5,10 +5,10 @@ Subject: [PATCH] Do not log invalid items in HoverEvent and ItemFrame
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc95f31fad0 100644
|
||||
index 67feb4e688d049e9f74f0deabb1ec583336a29be..63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
@@ -315,7 +315,7 @@ public class HoverEvent {
|
||||
@@ -314,7 +314,7 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(string);
|
||||
return new HoverEvent.ItemStackInfo(item, i, compoundTag);
|
||||
} catch (CommandSyntaxException var6) {
|
||||
@ -17,7 +17,7 @@ index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc9
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ public class HoverEvent {
|
||||
@@ -328,7 +328,7 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
return new HoverEvent.ItemStackInfo(ItemStack.of(compoundTag));
|
||||
} catch (CommandSyntaxException var2) {
|
||||
@ -27,10 +27,10 @@ index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc9
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||
index b829efdb40051a41b3bf1cabb8bf7d7c952797b5..a0f20bd54f713afe17c9b5fea9fdee6c59b6e219 100644
|
||||
index f134a2e68d50fba021b19fac4c75fb35d0e252c6..5e79ce09bf8ba48eb7f5dfdcf1511a2964c3281d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||
@@ -388,7 +388,7 @@ public class ItemFrame extends HangingEntity {
|
||||
@@ -396,7 +396,7 @@ public class ItemFrame extends HangingEntity {
|
||||
ItemStack itemstack = ItemStack.of(nbttagcompound1);
|
||||
|
||||
if (itemstack.isEmpty()) {
|
@ -1,54 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 14 Mar 2022 00:49:35 -0600
|
||||
Subject: [PATCH] Even more resource location validation
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
index 4733f74ff028c03a60b73280caf9e4d1e2f0ca30..02172fdcf587904258387d309938fb379a300524 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||
@@ -143,7 +143,7 @@ public class AreaEffectCloud extends Entity {
|
||||
}
|
||||
|
||||
public void setType(String string) {
|
||||
- this.setPotion(Registry.POTION.get(new ResourceLocation(string)));
|
||||
+ this.setPotion(Registry.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
index 1c446dba5de89698397041ee38a2e1a00bec8a56..93799eda06c7b699580251f80b641c47643f3615 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
@@ -513,7 +513,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||
}), (entity) -> {
|
||||
entity.load(nbt);
|
||||
}, () -> {
|
||||
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
|
||||
+ // Scissors - Don't log invalid entities
|
||||
});
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||
}
|
||||
|
||||
public static Optional<EntityType<?>> by(CompoundTag nbt) {
|
||||
- return Registry.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
||||
+ return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - Validate resource locations
|
||||
}
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 8837fc04a67a656d0e780965ac113d3b28e2369f..11427668a0af28cf638df3574357f696f49af13d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -570,7 +570,7 @@ public abstract class Mob extends LivingEntity {
|
||||
|
||||
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
||||
if (nbt.contains("DeathLootTable", 8)) {
|
||||
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
|
||||
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors - Validate resource locations
|
||||
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index 24f009fa3b84323b4c43e0ed15c224d16a7ede81..1d1876c78f82ce36d45320e4575c79fdc284ce0e 100644
|
||||
index fe87de42bc099ce41038f7f49ded9a12898e32eb..07fc1fefcea853ac0aa355312d8c718dc3a4ddd7 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -78,7 +78,12 @@ public final class NbtUtils {
|
||||
|
||||
@@ -77,7 +77,12 @@ public final class NbtUtils {
|
||||
}
|
||||
// Paper start - support string UUID's
|
||||
if (compound.contains("Id", 8)) {
|
||||
- uUID = UUID.fromString(compound.getString("Id"));
|
||||
@ -22,4 +22,4 @@ index 24f009fa3b84323b4c43e0ed15c224d16a7ede81..1d1876c78f82ce36d45320e4575c79fd
|
||||
+ // Scissors end
|
||||
}
|
||||
// Paper end
|
||||
if (compound.hasUUID("Id")) {
|
||||
|
@ -6,17 +6,17 @@ Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234..8018709dfce483a9000ada93cf47812fd49458a8 100644
|
||||
index 1fe46049cc33c24db04fbfcde36ab275c03177bf..a6d600ef4a90f54123ea53273bc83f1462f8e9f7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -45,6 +45,7 @@ import net.minecraft.nbt.NbtIo;
|
||||
@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
+import net.minecraft.resources.ResourceLocation; // Scissors
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
@@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||
|
@ -5,18 +5,18 @@ Subject: [PATCH] Don't query player data in the `nbt` component
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
index f5f2ec1192303bc55a64dce3e0457e4531a35ba7..62613d9fccd74fe16512fe1fe703dc6db0166b28 100644
|
||||
index 8e658eeb4edc83db72c187baa52b7ada7b848af8..e3dc56de3f91e03b1543257f72448a734d914ed7 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.nbt.Tag;
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -218,7 +219,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -217,7 +218,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||
protected Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
||||
if (this.compiledSelector != null) {
|
||||
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
@ -1,28 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 20 Mar 2022 04:39:09 -0600
|
||||
Subject: [PATCH] Fixes crash exploit related to out of bounds Axolotl variants
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index 2b8725087fd3bfeca7162bda2783fdacd13a8390..802c9c87df190dce09f9e703cedcb06874c58389 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -118,7 +118,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
|
||||
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fixes out of bounds Axolotl variant exploit
|
||||
this.setFromBucket(nbt.getBoolean("FromBucket"));
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
|
||||
@Override
|
||||
public void loadFromBucketTag(CompoundTag nbt) {
|
||||
Bucketable.loadDefaultDataFromBucketTag(this, nbt);
|
||||
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
|
||||
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fix out-of-bounds Axolotl variant exploit
|
||||
if (nbt.contains("Age")) {
|
||||
this.setAge(nbt.getInt("Age"));
|
||||
}
|
@ -5,10 +5,10 @@ Subject: [PATCH] Limit ListTags to 1024 elements
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
index 88bac72edf19c578902f49d20353989ed4d96f8f..6963f2720fcc9888f62f5a1382dd96d82f598ac8 100644
|
||||
index ea68b26e506e48d8238b7ee4266e61b211d52bd2..10d3a1b31233f884823ee9a4bb27d70eac3914df 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
@@ -34,6 +34,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
@@ -33,6 +33,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 20 Mar 2022 07:46:37 -0600
|
||||
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
||||
when handling Creative Inventory packets
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 621ec8e8a197323da6b423fee57c816ac9d7c875..83333ae9c8e8c1edc6e7f02468bd8dc7e44bb66e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2933,20 +2933,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
if (this.player.gameMode.isCreative()) {
|
||||
boolean flag = packet.getSlotNum() < 0;
|
||||
ItemStack itemstack = packet.getItem();
|
||||
- CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
||||
|
||||
+ CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
||||
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
||||
BlockPos blockposition = new BlockPos(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
||||
- BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
+ // Scissors start - Validate coordinates and whether or not the player can reach them
|
||||
+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) {
|
||||
+ BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
|
||||
- if (tileentity != null) {
|
||||
- CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
||||
+ if (tileentity != null) {
|
||||
+ CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
||||
|
||||
- nbttagcompound1.remove("x");
|
||||
- nbttagcompound1.remove("y");
|
||||
- nbttagcompound1.remove("z");
|
||||
- itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
||||
+ nbttagcompound1.remove("x");
|
||||
+ nbttagcompound1.remove("y");
|
||||
+ nbttagcompound1.remove("z");
|
||||
+ itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
||||
+ }
|
||||
}
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
index 79e036d79dec2ec4404baf02c23ba5ccad20cdce..506be74453c6ecc52f05a48b1d95f82175fa6159 100644
|
||||
index 8bbb9bdcf95989f1737714655f6f6a269d46d7f2..3f5df0a365ddafe4277988767f8366536b928dab 100644
|
||||
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
@@ -47,6 +47,7 @@ public class MobEffect {
|
@ -1,199 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 13:19:43 -0600
|
||||
Subject: [PATCH] Better handling of invalid JSON components
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index 5ba1636bbb938373e43c1f3ac561368fc9cffd43..6978d14c6bd90ffb640e39e8666430d95d5ef45c 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -24,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
@@ -427,6 +429,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return Component.Serializer.GSON.toJsonTree(text);
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ @Nullable
|
||||
+ public static MutableComponent fromJsonSafe(String json) {
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public static MutableComponent fromJsonSafe(JsonElement json) {
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Nullable
|
||||
public static MutableComponent fromJson(String json) {
|
||||
return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false);
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
index 9c1341803cf892f7f3af11381bd56bc95f31fad0..c4394812326bccd70d64b4bd45eb1bb7b53b0905 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
@@ -80,7 +80,7 @@ public class HoverEvent {
|
||||
if (jsonElement != null) {
|
||||
return action.deserialize(jsonElement);
|
||||
} else {
|
||||
- Component component = Component.Serializer.fromJson(json.get("value"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(json.get("value")); // Scissors - Use safer method for getting Components from JSON
|
||||
return component != null ? action.deserializeFromLegacy(component) : null;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class HoverEvent {
|
||||
}
|
||||
|
||||
public static class Action<T> {
|
||||
- public static final HoverEvent.Action<Component> SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJson, Component.Serializer::toJsonTree, Function.identity());
|
||||
+ public static final HoverEvent.Action<Component> SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJsonSafe, Component.Serializer::toJsonTree, Function.identity()); // Scissors - Use safer method for getting Components from JSON
|
||||
public static final HoverEvent.Action<HoverEvent.ItemStackInfo> SHOW_ITEM = new HoverEvent.Action<>("show_item", true, HoverEvent.ItemStackInfo::create, HoverEvent.ItemStackInfo::serialize, HoverEvent.ItemStackInfo::create);
|
||||
public static final HoverEvent.Action<HoverEvent.EntityTooltipInfo> SHOW_ENTITY = new HoverEvent.Action<>("show_entity", true, HoverEvent.EntityTooltipInfo::create, HoverEvent.EntityTooltipInfo::serialize, HoverEvent.EntityTooltipInfo::create);
|
||||
private static final Map<String, HoverEvent.Action<?>> LOOKUP = Stream.of(SHOW_TEXT, SHOW_ITEM, SHOW_ENTITY).collect(ImmutableMap.toImmutableMap(HoverEvent.Action::getName, (action) -> {
|
||||
@@ -183,7 +183,7 @@ public class HoverEvent {
|
||||
return null;
|
||||
}
|
||||
// Scissors end
|
||||
- Component component = Component.Serializer.fromJson(jsonObject.get("name"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(jsonObject.get("name")); // Scissors - Use safer method for getting Components from JSON
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class HoverEvent {
|
||||
public static HoverEvent.EntityTooltipInfo create(Component text) {
|
||||
try {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("name")); // Scissors - Use safer method for getting Components from JSON
|
||||
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||
// Scissors start
|
||||
UUID uUID;
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
index ae9fef071388bc6b10d34a0126c9dd1ac77eb9e7..f5f2ec1192303bc55a64dce3e0457e4531a35ba7 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
@@ -77,13 +77,14 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||
if (this.interpreting) {
|
||||
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
|
||||
return stream.flatMap((text) -> {
|
||||
+ // Scissors start - Use safer method for getting Components from JSON
|
||||
try {
|
||||
- MutableComponent mutableComponent = Component.Serializer.fromJson(text);
|
||||
+ MutableComponent mutableComponent = Component.Serializer.fromJsonSafe(text);
|
||||
return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth));
|
||||
} catch (Exception var5) {
|
||||
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||
return Stream.of();
|
||||
}
|
||||
+ // Scissors end
|
||||
}).reduce((accumulator, current) -> {
|
||||
return accumulator.append(component).append(current);
|
||||
}).orElseGet(() -> {
|
||||
@@ -94,7 +95,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||
return stream.map((string) -> {
|
||||
return new TextComponent(string);
|
||||
}).reduce((accumulator, current) -> {
|
||||
- return accumulator.append(text).append(current);
|
||||
+ return (TextComponent) accumulator.append(text).append(current);
|
||||
}).orElseGet(() -> {
|
||||
return new TextComponent("");
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index b7c4700fd5db14c77e7ee78311dd77a754d9d41c..07f04c1708b118ace3ed73ae2bf88c29b1c80ad2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2202,12 +2202,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
String s = nbt.getString("CustomName");
|
||||
-
|
||||
- try {
|
||||
- this.setCustomName(Component.Serializer.fromJson(s));
|
||||
- } catch (Exception exception) {
|
||||
- Entity.LOGGER.warn("Failed to parse entity custom name {}", s, exception);
|
||||
- }
|
||||
+ this.setCustomName(Component.Serializer.fromJsonSafe(s)); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
index 3281448bf37da8a1b4b7b44f10f4b2438b4a4f29..8038e3a10b563321df1e8cedd26b256078ce745a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -405,7 +405,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
||||
// CraftBukkit end
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
index 40ac65501a0213b43964fd68eb155d4358fb7fd4..9cfc44472e841e1a2cd7de2a1284afdde05a7989 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
@@ -44,7 +44,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
index 2153e7035535990b5307b85d8bc3dab50c0a3ae8..5f11f9b77684bd91b4cfe77cd415ed42bd9bc21a 100644
|
||||
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
@@ -39,7 +39,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
}
|
||||
|
||||
PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string);
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component != null) {
|
||||
playerTeam.setDisplayName(component);
|
||||
}
|
||||
@@ -57,14 +57,14 @@ public class ScoreboardSaveData extends SavedData {
|
||||
}
|
||||
|
||||
if (compoundTag.contains("MemberNamePrefix", 8)) {
|
||||
- Component component2 = Component.Serializer.fromJson(compoundTag.getString("MemberNamePrefix"));
|
||||
+ Component component2 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNamePrefix")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component2 != null) {
|
||||
playerTeam.setPlayerPrefix(component2);
|
||||
}
|
||||
}
|
||||
|
||||
if (compoundTag.contains("MemberNameSuffix", 8)) {
|
||||
- Component component3 = Component.Serializer.fromJson(compoundTag.getString("MemberNameSuffix"));
|
||||
+ Component component3 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNameSuffix")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component3 != null) {
|
||||
playerTeam.setPlayerSuffix(component3);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
string = string.substring(0, 16);
|
||||
}
|
||||
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType"));
|
||||
this.scoreboard.addObjective(string, objectiveCriteria, component, renderType);
|
||||
});
|
@ -1,162 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ayunami2000 <spwilliamsiam@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 17:02:21 -0400
|
||||
Subject: [PATCH] block server-side chunkbans
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
index b039a32b805fc02033fa862a1c40c4a51639e69a..1d407ebea9ff2932f93b7d6842b0e2a4e801b48c 100644
|
||||
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
@@ -4,9 +4,17 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
+
|
||||
import java.io.IOException;
|
||||
+
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
+import net.minecraft.network.protocol.game.*;
|
||||
+import net.minecraft.network.syncher.SynchedEntityData;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -44,27 +52,93 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
packet.write(friendlyByteBuf);
|
||||
int j = friendlyByteBuf.writerIndex() - i;
|
||||
if (j > 8388608) {
|
||||
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
|
||||
+ // Scissors start
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
|
||||
+ // Scissors end
|
||||
}
|
||||
} catch (Throwable var9) {
|
||||
+ // Scissors start
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
+ /*
|
||||
LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var9); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
|
||||
if (packet.isSkippable()) {
|
||||
throw new SkipPacketException(var9);
|
||||
} else {
|
||||
throw var9;
|
||||
}
|
||||
+ */
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
// Paper start
|
||||
int packetLength = friendlyByteBuf.readableBytes();
|
||||
if (packetLength > MAX_PACKET_SIZE) {
|
||||
- throw new PacketTooLargeException(packet, packetLength);
|
||||
+ // Scissors start
|
||||
+ friendlyByteBuf.clear();
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
+ packetLength = friendlyByteBuf.readableBytes();
|
||||
+ if (packetLength > MAX_PACKET_SIZE) {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ //throw new PacketTooLargeException(packet, packetLength);
|
||||
+ }
|
||||
+ //throw new PacketTooLargeException(packet, packetLength);
|
||||
+ // Scissors end
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ private static void noKicking(FriendlyByteBuf friendlyByteBuf, Packet packet, Integer integer, ChannelHandlerContext channelHandlerContext) {
|
||||
+ // no kicking!!
|
||||
+ friendlyByteBuf.clear();
|
||||
+ friendlyByteBuf.writeVarInt(integer);
|
||||
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
||||
+ boolean didIt = true;
|
||||
+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) {
|
||||
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
|
||||
+ } else if (packet instanceof ClientboundLevelChunkPacket chunkPacket) {
|
||||
+ chunkPacket.clearNbt();
|
||||
+ } else if (packet instanceof ClientboundSetEntityDataPacket entityDataPacket) {
|
||||
+ friendlyByteBuf.writeVarInt(entityDataPacket.getId());
|
||||
+ friendlyByteBuf.writeByte(255);
|
||||
+ didIt = false;//prevent default packet writing
|
||||
+ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) {
|
||||
+ containerSetContentPacket.clearNbt();
|
||||
+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) {
|
||||
+ friendlyByteBuf.writeVarInt(setEquipmentPacket.getEntity());
|
||||
+ didIt = false;//prevent default
|
||||
+ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) {
|
||||
+ //i really would rather cancel this packet entirely buuut idk how sOOOOoooo
|
||||
+ friendlyByteBuf.writeByte(containerSetSlotPacket.getContainerId());
|
||||
+ friendlyByteBuf.writeVarInt(containerSetSlotPacket.getStateId());
|
||||
+ friendlyByteBuf.writeShort(containerSetSlotPacket.getSlot());
|
||||
+ friendlyByteBuf.writeItem(ItemStack.EMPTY);
|
||||
+ didIt = false;//prevent default
|
||||
+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) {
|
||||
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(),mapItemDataPacket.getScale(),mapItemDataPacket.isLocked(),null,null);
|
||||
+ } else {
|
||||
+ didIt = false;
|
||||
+ LOGGER.info(packet.getClass().getName() + " overflowed/errored and was not caught!!");
|
||||
+ }
|
||||
+ if (didIt) {
|
||||
+ try {
|
||||
+ int i = friendlyByteBuf.writerIndex();
|
||||
+ packet.write(friendlyByteBuf);
|
||||
+ int j = friendlyByteBuf.writerIndex() - i;
|
||||
+ if (j > 8388608) {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
|
||||
+ }
|
||||
+ } catch (Throwable var69) {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Paper start
|
||||
private static int MAX_PACKET_SIZE = 2097152;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
index dbd8b9b09b82c1b75e8be9dc7416d9f0863c8c87..f71f68d1482f7e0481a95533e42e8ee5089f15ff 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
@@ -10,7 +10,14 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
|
||||
private final int containerId;
|
||||
private final int stateId;
|
||||
private final List<ItemStack> items;
|
||||
- private final ItemStack carriedItem;
|
||||
+ private ItemStack carriedItem; // Scissors - removed "final"
|
||||
+
|
||||
+ // Scissors start
|
||||
+ public void clearNbt(){
|
||||
+ this.items.clear();
|
||||
+ this.carriedItem = ItemStack.EMPTY;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
|
||||
public ClientboundContainerSetContentPacket(int syncId, int revision, NonNullList<ItemStack> contents, ItemStack cursorStack) {
|
||||
this.containerId = syncId;
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
index 60d72e488bc77cd913328be400ca374a873b4561..89c385c5ec88c8b51f9e118b65f3b9c2a58c7d9b 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
@@ -50,6 +50,13 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Scissors start
|
||||
+ public void clearNbt() {
|
||||
+ this.blockEntitiesTags.clear();
|
||||
+ this.extraPackets.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Paper start - Anti-Xray - Add chunk packet info
|
||||
@Deprecated public ClientboundLevelChunkPacket(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
|
||||
public ClientboundLevelChunkPacket(LevelChunk chunk, boolean modifyBlocks) {
|
@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 16:49:17 -0600
|
||||
Subject: [PATCH] Reject oversized components from updating
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
index 8f4c83837d0b01a3dbca2607ea718c371db48ef4..fe2717679f84fbef1b8ff1f9a3c3bf0fba8965f1 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
@@ -37,8 +37,11 @@ public class ComponentUtils {
|
||||
}
|
||||
|
||||
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||
+ // Scissors start - Reject oversized components
|
||||
+ MutableComponent result;
|
||||
+
|
||||
if (depth > 100) {
|
||||
- return text.copy();
|
||||
+ result = text.copy();
|
||||
} else {
|
||||
MutableComponent mutableComponent = text instanceof ContextAwareComponent ? ((ContextAwareComponent)text).resolve(source, sender, depth + 1) : text.plainCopy();
|
||||
|
||||
@@ -46,8 +49,12 @@ public class ComponentUtils {
|
||||
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
||||
}
|
||||
|
||||
- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||
}
|
||||
+
|
||||
+ // Would the resulting component exceed 65535 bytes when encoded as a string?
|
||||
+ return Component.Serializer.toJson(result).length() > 65535 ? new TextComponent("") : result;
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
@ -1,95 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Mon, 4 Apr 2022 00:16:54 +0100
|
||||
Subject: [PATCH] Prevent abusable entities from being spawned by spawners
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
index 569cef8fcb1e3e1e8b66dad4fa9b956b44542bf1..f844e0b1e44f0b45b1febadf02d7b37d3099fbdb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
@@ -19,7 +19,9 @@ import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
+import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.SpawnPlacements;
|
||||
@@ -31,6 +33,7 @@ public abstract class BaseSpawner {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final int EVENT_SPAWN = 1;
|
||||
+ public static List<MobCategory> whitelistedCategories = List.of(MobCategory.CREATURE, MobCategory.MONSTER, MobCategory.WATER_CREATURE, MobCategory.UNDERGROUND_WATER_CREATURE, MobCategory.AMBIENT); // Scissors
|
||||
public static WeightedRandomList<SpawnData> EMPTY_POTENTIALS = WeightedRandomList.create(); // Paper - private->public
|
||||
public int spawnDelay = 20;
|
||||
public WeightedRandomList<SpawnData> spawnPotentials;
|
||||
@@ -64,6 +67,13 @@ public abstract class BaseSpawner {
|
||||
public ResourceLocation getEntityId(@Nullable Level world, BlockPos pos) {
|
||||
String s = this.nextSpawnData.getTag().getString("id");
|
||||
|
||||
+ // Scissors start
|
||||
+ Optional<EntityType<?>> entityType = EntityType.byString(s);
|
||||
+ if (entityType.isPresent() && !whitelistedCategories.contains(entityType.get().getCategory())) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
try {
|
||||
return StringUtil.isNullOrEmpty(s) ? null : new ResourceLocation(s);
|
||||
} catch (ResourceLocationException resourcekeyinvalidexception) {
|
||||
@@ -73,6 +83,12 @@ public abstract class BaseSpawner {
|
||||
}
|
||||
|
||||
public void setEntityId(EntityType<?> type) {
|
||||
+ // Scissors start - Don't allow unnatural entities to be added to spawners
|
||||
+ if (!whitelistedCategories.contains(type.getCategory())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
this.nextSpawnData.getTag().putString("id", Registry.ENTITY_TYPE.getKey(type).toString());
|
||||
this.spawnPotentials = BaseSpawner.EMPTY_POTENTIALS; // CraftBukkit - SPIGOT-3496, MC-92282
|
||||
}
|
||||
@@ -121,7 +137,7 @@ public abstract class BaseSpawner {
|
||||
CompoundTag nbttagcompound = this.nextSpawnData.getTag();
|
||||
Optional<EntityType<?>> optional = EntityType.by(nbttagcompound);
|
||||
|
||||
- if (!optional.isPresent()) {
|
||||
+ if (!(optional.isPresent() && whitelistedCategories.contains(optional.get().getCategory()))) { // Scissors - Don't try spawning in entites that aren't whitelisted
|
||||
this.delay(world, pos);
|
||||
return;
|
||||
}
|
||||
@@ -254,12 +270,16 @@ public abstract class BaseSpawner {
|
||||
ListTag nbttaglist = nbt.getList("SpawnPotentials", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
- list.add(new SpawnData(nbttaglist.getCompound(i)));
|
||||
+ // Scissors start - Filter unnatural entity types from being added
|
||||
+ if (isValid(nbttaglist.getCompound(i))) {
|
||||
+ list.add(new SpawnData(nbttaglist.getCompound(i)));
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
||||
this.spawnPotentials = WeightedRandomList.create((List) list);
|
||||
- if (nbt.contains("SpawnData", 10)) {
|
||||
+ if (nbt.contains("SpawnData", 10) && isValid(nbt.getCompound("SpawnData"))) { // Scissors - Filter unnatural entity types from being added
|
||||
this.setNextSpawnData(world, pos, new SpawnData(1, nbt.getCompound("SpawnData")));
|
||||
} else if (!list.isEmpty()) {
|
||||
this.spawnPotentials.getRandom(this.random).ifPresent((mobspawnerdata) -> {
|
||||
@@ -371,4 +391,11 @@ public abstract class BaseSpawner {
|
||||
public double getoSpin() {
|
||||
return this.oSpin;
|
||||
}
|
||||
+
|
||||
+ // Scissors start
|
||||
+ public boolean isValid(CompoundTag tag) {
|
||||
+ Optional<EntityType<?>> type = EntityType.by(tag);
|
||||
+ return type.isPresent() && whitelistedCategories.contains(type.get().getCategory());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
@ -1,249 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Mon, 18 Apr 2022 03:56:09 +0100
|
||||
Subject: [PATCH] Reset large tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..058203440fd071ce5edbe18391ea60f0a5fbee3a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package com.github.atlasmediagroup.scissors;
|
||||
+
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+
|
||||
+public class NbtUtility
|
||||
+{
|
||||
+
|
||||
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||
+ {
|
||||
+ if (tag == null) return false;
|
||||
+ return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024);
|
||||
+ }
|
||||
+
|
||||
+ public static class Item
|
||||
+ {
|
||||
+
|
||||
+ public static CompoundTag removeItemData(CompoundTag tag)
|
||||
+ {
|
||||
+ CompoundTag cleaned = new CompoundTag();
|
||||
+ cleaned.putString("id", tag.getString("id"));
|
||||
+ cleaned.putByte("Count", tag.getByte("Count"));
|
||||
+ return cleaned;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index d02339a07e1da56fd5dc171a5e32b00d63fa555c..fe6cb52573ee50a2c02d7add38b5e8411d7177f4 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.item;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
@@ -7,23 +8,28 @@ import com.google.gson.JsonParseException;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.serialization.Codec;
|
||||
+import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
-import java.text.DecimalFormat;
|
||||
-import java.text.DecimalFormatSymbols;
|
||||
-import java.util.Collection;
|
||||
-import java.util.Iterator;
|
||||
-import java.util.List;
|
||||
-import java.util.Collections;
|
||||
-import java.util.Comparator;
|
||||
-import java.util.Locale;
|
||||
-import java.util.Map.Entry;
|
||||
-import java.util.Objects;
|
||||
-import java.util.Optional;
|
||||
-import java.util.Random;
|
||||
-import java.util.function.Consumer;
|
||||
-import java.util.function.Predicate;
|
||||
-import java.util.stream.Collectors;
|
||||
-import javax.annotation.Nullable;
|
||||
+import net.minecraft.ChatFormatting;
|
||||
+import net.minecraft.Util;
|
||||
+import net.minecraft.advancements.CriteriaTriggers;
|
||||
+import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
+import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.Direction;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import net.minecraft.nbt.NbtOps;
|
||||
+import net.minecraft.network.chat.*;
|
||||
+import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.sounds.SoundSource;
|
||||
+import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagContainer;
|
||||
@@ -31,11 +37,7 @@ import net.minecraft.util.datafix.fixes.References;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
-import net.minecraft.world.entity.Entity;
|
||||
-import net.minecraft.world.entity.EquipmentSlot;
|
||||
-import net.minecraft.world.entity.LivingEntity;
|
||||
-import net.minecraft.world.entity.MobType;
|
||||
-import net.minecraft.world.entity.SlotAccess;
|
||||
+import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
@@ -51,50 +53,13 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
-import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
-import net.minecraft.world.level.block.Block;
|
||||
-import org.apache.logging.log4j.LogManager;
|
||||
-import org.apache.logging.log4j.Logger;
|
||||
-
|
||||
-// CraftBukkit start
|
||||
-import com.mojang.serialization.Dynamic;
|
||||
-import java.util.List;
|
||||
-import java.util.Map;
|
||||
-import net.minecraft.ChatFormatting;
|
||||
-import net.minecraft.Util;
|
||||
-import net.minecraft.advancements.CriteriaTriggers;
|
||||
-import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
-import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
-import net.minecraft.core.BlockPos;
|
||||
-import net.minecraft.core.Direction;
|
||||
-import net.minecraft.core.Registry;
|
||||
-import net.minecraft.nbt.CompoundTag;
|
||||
-import net.minecraft.nbt.ListTag;
|
||||
-import net.minecraft.nbt.NbtOps;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.ComponentUtils;
|
||||
-import net.minecraft.network.chat.HoverEvent;
|
||||
-import net.minecraft.network.chat.MutableComponent;
|
||||
-import net.minecraft.network.chat.Style;
|
||||
-import net.minecraft.network.chat.TextComponent;
|
||||
-import net.minecraft.network.chat.TranslatableComponent;
|
||||
-import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
-import net.minecraft.resources.ResourceLocation;
|
||||
-import net.minecraft.server.MinecraftServer;
|
||||
-import net.minecraft.server.level.ServerLevel;
|
||||
-import net.minecraft.server.level.ServerPlayer;
|
||||
-import net.minecraft.sounds.SoundEvent;
|
||||
-import net.minecraft.sounds.SoundSource;
|
||||
-import net.minecraft.stats.Stats;
|
||||
-import net.minecraft.world.level.block.Blocks;
|
||||
-import net.minecraft.world.level.block.JukeboxBlock;
|
||||
-import net.minecraft.world.level.block.SaplingBlock;
|
||||
-import net.minecraft.world.level.block.SoundType;
|
||||
-import net.minecraft.world.level.block.WitherSkullBlock;
|
||||
+import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -106,6 +71,15 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockFertilizeEvent;
|
||||
import org.bukkit.event.player.PlayerItemDamageEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.text.DecimalFormat;
|
||||
+import java.text.DecimalFormatSymbols;
|
||||
+import java.util.*;
|
||||
+import java.util.Map.Entry;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Predicate;
|
||||
+import java.util.stream.Collectors;
|
||||
// CraftBukkit end
|
||||
|
||||
public final class ItemStack {
|
||||
@@ -245,6 +219,13 @@ public final class ItemStack {
|
||||
|
||||
// CraftBukkit - break into own method
|
||||
private void load(CompoundTag nbttagcompound) {
|
||||
+ // Scissors start - Reset large tags
|
||||
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
||||
+ // Reset tag without destroying item
|
||||
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
this.item = (Item) Registry.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -485,7 +466,11 @@ public final class ItemStack {
|
||||
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
|
||||
nbt.putByte("Count", (byte) this.count);
|
||||
if (this.tag != null) {
|
||||
- nbt.put("tag", this.tag.copy());
|
||||
+ // Scissors start - Don't save large tags
|
||||
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
||||
+ nbt.put("tag", this.tag.copy());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
return nbt;
|
||||
@@ -815,6 +800,9 @@ public final class ItemStack {
|
||||
}
|
||||
// Paper end
|
||||
public void setTag(@Nullable CompoundTag nbt) {
|
||||
+ // Scissors start - Ignore large tags
|
||||
+ if (NbtUtility.isTooLarge(nbt)) return;
|
||||
+ // Scissors end
|
||||
this.tag = nbt;
|
||||
processEnchantOrder(this.tag); // Paper
|
||||
if (this.getItem().canBeDepleted()) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index 14da2997b5fff4434b1fe8d5a1b3109dde143740..a4385cea2d472611cfc7ef43662367bb1d780333 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -1,16 +1,12 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
-import static org.bukkit.craftbukkit.inventory.CraftMetaItem.*;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
-import java.util.Map;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
-import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
-import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
|
||||
import org.bukkit.craftbukkit.util.CraftLegacy;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
@@ -19,6 +15,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
+import java.util.Map;
|
||||
+
|
||||
+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_ID;
|
||||
+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_LVL;
|
||||
+
|
||||
@DelegateDeserialization(ItemStack.class)
|
||||
public final class CraftItemStack extends ItemStack {
|
||||
|
Loading…
Reference in New Issue
Block a user