Prepare for 1.19

This commit is contained in:
Telesphoreo 2022-06-10 22:11:51 -05:00
parent 46668157cb
commit 38914f1604
33 changed files with 13 additions and 1975 deletions

View File

@ -1,8 +1,8 @@
group=me.totalfreedom.scissors group=me.totalfreedom.scissors
version=1.18.2-R0.1-SNAPSHOT version=1.19-R0.1-SNAPSHOT
mcVersion=1.18.2 mcVersion=1.19
paperRef=276d830d223ddf68611beacc248285ae5a4e8a1f paperRef=76f81aec25f04056c1f681482cf31071a75ea748
org.gradle.caching=true org.gradle.caching=true
org.gradle.parallel=true org.gradle.parallel=true

View File

@ -1,11 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me> From: Telesphoreo <me@telesphoreo.me>
Date: Tue, 19 Apr 2022 18:17:43 -0500 Date: Fri, 10 Jun 2022 22:10:10 -0500
Subject: [PATCH] Build changes Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index 0282e3b75470e1a68ea1fc228082483514ba432e..9e78384fdd5727143d3be5f189478ed701fbd0bd 100644 index eefbd0a742b5875e0e9826b87c6bd4da66b2d7f7..83005bdd467eb5385c959f77806738100a6fa5ae 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -9,8 +9,8 @@ plugins { @@ -9,8 +9,8 @@ plugins {
@ -15,11 +15,11 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9e78384fdd5727143d3be5f189478ed7
- implementation(project(":paper-api")) - implementation(project(":paper-api"))
- implementation(project(":paper-mojangapi")) - implementation(project(":paper-mojangapi"))
+ implementation(project(":Scissors-API")) + implementation(project(":Scissors-API"))
+ implementation("io.papermc.paper:paper-mojangapi:1.18.2-R0.1-SNAPSHOT") // Scissors + implementation("io.papermc.paper:paper-mojangapi:1.19-R0.1-SNAPSHOT")
// Paper start // Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0") implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -56,11 +56,17 @@ tasks.jar { @@ -58,11 +58,17 @@ tasks.jar {
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
@ -39,7 +39,7 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9e78384fdd5727143d3be5f189478ed7
"Implementation-Vendor" to date, // Paper "Implementation-Vendor" to date, // Paper
"Specification-Title" to "Bukkit", "Specification-Title" to "Bukkit",
"Specification-Version" to project.version, "Specification-Version" to project.version,
@@ -148,7 +154,7 @@ fun TaskContainer.registerRunTask( @@ -150,7 +156,7 @@ fun TaskContainer.registerRunTask(
name: String, name: String,
block: JavaExec.() -> Unit block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) { ): TaskProvider<JavaExec> = register<JavaExec>(name) {
@ -49,23 +49,23 @@ index 0282e3b75470e1a68ea1fc228082483514ba432e..9e78384fdd5727143d3be5f189478ed7
standardInput = System.`in` standardInput = System.`in`
workingDir = rootProject.layout.projectDirectory workingDir = rootProject.layout.projectDirectory
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index da15a224b8b974e78b9d8d5f514229b3b2a5a63e..8ca2e2e3d2564ec0cc081ff52334484dd5561e5c 100644 index 9e1d3a22ed7e34e4968b5fb34cc77b661eb4747d..4fc83abdcbe23a1790fb3958c193915e91354dcd 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1696,7 +1696,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1654,7 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
- return "Paper"; // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! - return "Paper"; // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
+ return "Scissors"; // Scissors - Scissors > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! + return "Scissors"; // Scissors - Scissors // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
} }
public SystemReport fillSystemReport(SystemReport details) { public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 8a248e34fce1e04de4460f98b7627df495c66af1..ebd5aeceb4ac1a6300bbfa70218421f0d91b7614 100644 index f1e5ccfbcd08a73ac3aba9a1cb7b414faef81f9e..d60237a818cecc60e9e3fcb17fe329d88fdf03e5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -249,7 +249,7 @@ import javax.annotation.Nullable; // Paper @@ -243,7 +243,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server { public final class CraftServer implements Server {

View File

@ -1,42 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sat, 12 Mar 2022 19:34:59 -0700
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 b31ff9d237f593e58b42b453632aa2c2af74f986..67feb4e688d049e9f74f0deabb1ec583336a29be 100644
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
@@ -174,7 +174,14 @@ public class HoverEvent {
} else {
JsonObject jsonObject = json.getAsJsonObject();
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(GsonHelper.getAsString(jsonObject, "type")));
- UUID uUID = UUID.fromString(GsonHelper.getAsString(jsonObject, "id"));
+ // Scissors start
+ UUID uUID;
+ try {
+ uUID = UUID.fromString(GsonHelper.getAsString(jsonObject, "id"));
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
Component component = Component.Serializer.fromJson(jsonObject.get("name"));
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
}
@@ -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")));
- UUID uUID = UUID.fromString(compoundTag.getString("id"));
+ // Scissors start
+ UUID uUID;
+ try {
+ uUID = UUID.fromString(compoundTag.getString("id"));
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
} catch (Exception var5) {
return null;

View File

@ -1,46 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sun, 13 Mar 2022 07:39:26 -0600
Subject: [PATCH] Fixes invalid LootTables causing problems when applied to
Minecart entities
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
index 83dd3c254fd10e4596e454cc75c8e5e976b73ac0..1b2533bbbc62bcb0d00789312ba72a49f8f49f42 100644
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
@@ -16,7 +16,7 @@ public class PaperMinecartLootableInventory implements PaperLootableEntityInvent
@Override
public org.bukkit.loot.LootTable getLootTable() {
- return entity.lootTable != null && !entity.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null;
+ return entity.lootTable != null && !entity.lootTable.getPath().isEmpty() && entity.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
}
@Override
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
index 94dc68182ec5f6dc1294ad15523427836228086a..07075cea760562c901d4469a7f88271c3ffa30bb 100644
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven
@Override
public org.bukkit.loot.LootTable getLootTable() {
- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null;
+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
}
@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 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
this.lootableData.loadNbt(nbt); // Paper
this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
if (nbt.contains("LootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables
this.lootTableSeed = nbt.getLong("LootTableSeed");
} if (true) { // Paper - always load the items, table may still remain
ContainerHelper.loadAllItems(nbt, this.itemStacks);

View File

@ -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 483dc52c793d9f90a35b1d091dd8ce71115e4640..61097643950b1182e3751c6a4629cf5661dcf3b8 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;
@@ -367,6 +368,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);

View File

@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 00:59:00 -0500
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 292ae4a68093b7d939a755e1062cee57da186ab1..4ae030580131252b849fd356717d0323c29cf773 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
@@ -7,6 +7,9 @@ import java.util.UUID;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
+// Scissors start
+import org.apache.commons.lang3.StringUtils;
+// Scissors end
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@@ -45,7 +48,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)));
}
}

View File

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Sun, 13 Mar 2022 11:07:34 -0300
Subject: [PATCH] Ignore null/air bundle items in CraftMetaBundle
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
index 8fd1e392258eba9dbe2194c024ad7e0ca3e43cf8..28be42594857f2d8320a035c1f8b95cdc300ddd5 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
@@ -49,7 +49,11 @@ public class CraftMetaBundle extends CraftMetaItem implements BundleMeta {
for (int i = 0; i < list.size(); i++) {
CompoundTag nbttagcompound1 = list.getCompound(i);
- this.addItem(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1)));
+ // Scissors start
+ CraftItemStack item = CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1));
+ if(item == null || item.getType().isAir()) continue;
+ this.addItem(item);
+ // Scissors end
}
}
}

View File

@ -1,28 +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 5607dc10dc1c9d2dbf4e3007890e5e89a175605e..bc30df2009cf0d8edf0040f6fe16587d109cebdb 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1769,6 +1769,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
try {
blockParser = blockParser.parse(false);
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
+ // Scissors - Don't log errors thrown by Brigadier when an error is thrown
return null;
}
@@ -1794,8 +1795,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;

View File

@ -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 ef50d9747f2a027e356b05ad8d94ffb2fd4a423e..cd8ede69be1f728663a670085113d842ec0209af 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, (Entity) this, (Container) this);
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
+ try {
+ Containers.dropContents(this.level, (Entity) this, (Container) this);
+ } catch (Exception ignored) {
+ }
+ // Scissors end
}
super.remove(reason);

View File

@ -1,26 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Sun, 13 Mar 2022 14:38:38 -0300
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 9ca37cbf829ff4240ae79fc283bcf9e7f2c728d2..bc71ca6e082a137d17ee0bf43de72095bd19ab3d 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -379,11 +379,14 @@ public class ItemEntity extends Entity {
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
- this.setItem(ItemStack.of(nbttagcompound1));
+ // Scissors start
if (this.getItem().isEmpty()) {
this.discard();
+ return;
}
+ this.setItem(ItemStack.of(nbttagcompound1));
+ // Scissors end
}
@Override

View File

@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sun, 13 Mar 2022 18:42:07 -0600
Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is
provided
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
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 {
for(int i = 0; i < listTag.size(); ++i) {
String string = listTag.getString(i);
- Optional<? extends Recipe<?>> optional = recipeManager.byKey(new ResourceLocation(string));
+ Optional<? extends Recipe<?>> optional = recipeManager.byKey(ResourceLocation.tryParse(string)); // Scissors - Validate resource locations
if (!optional.isPresent()) {
- LOGGER.error("Invalid recipe: {}", (Object)string);
+ // Scissors - Don't log errors caused by invalid recipes being provided
return InteractionResultHolder.fail(itemStack);
}
@@ -55,7 +55,7 @@ public class KnowledgeBookItem extends Item {
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
} else {
- LOGGER.error("Tag not valid: {}", (Object)compoundTag);
+ // Scissors - Don't throw errors into the logs if an NBT compound isn't present or is missing the Recipes tag.
return InteractionResultHolder.fail(itemStack);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
index e816e505cd292d6c5138dff0aeae0e9592c09de0..0f6438dfe0a6620eb87233b9eefbe2340dfc347b 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
@@ -42,7 +42,12 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
for (int i = 0; i < pages.size(); i++) {
String recipe = pages.getString(i);
- this.addRecipe(CraftNamespacedKey.fromString(recipe));
+ // Scissors start - Don't add recipes with invalid namespaces
+ try {
+ this.addRecipe(CraftNamespacedKey.fromString(recipe));
+ } catch (Exception ignored) {
+ }
+ // Scissors end
}
}
}

View File

@ -1,32 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sun, 13 Mar 2022 21:56:29 -0600
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 050ee055b9a2a0767f58d6677ad7f2d927fbaa54..9ec5bc2c29fc98ac2fbf9ff6231e8c3215ff11a1 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -229,7 +229,7 @@ public final class NbtUtils {
if (!compound.contains("Name", 8)) {
return Blocks.AIR.defaultBlockState();
} else {
- Block block = Registry.BLOCK.get(new ResourceLocation(compound.getString("Name")));
+ Block block = Registry.BLOCK.get(ResourceLocation.tryParse(compound.getString("Name"))); // Scissors - Validate BlockState
BlockState blockState = block.defaultBlockState();
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 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
@@ -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)) {
- this.soundEvent = (SoundEvent) Registry.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent());
+ this.soundEvent = (SoundEvent) Registry.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Scissors - Validate SoundEvents before trying to play them
}
this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow"));

View File

@ -1,86 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Mon, 9 May 2022 23:40:59 -0500
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 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 {
try {
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle"))));
} catch (CommandSyntaxException commandsyntaxexception) {
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
+ // Scissors - Don't log custom particle errors
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
@@ -30,8 +30,14 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity>
return null;
}
- ResourceLocation key = getSnapshot().lootTable;
- return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ ResourceLocation key = getSnapshot().lootTable;
+ return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf11cf046fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
@@ -33,8 +33,14 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
return null; // return empty loot table?
}
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
- return Bukkit.getLootTable(key);
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
+ return Bukkit.getLootTable(key);
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index d775e19402188e35f79affb4ed636b6533f90ab5..29f5ab80ffbc421da911046678427755c6156894 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -63,8 +63,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
@Override
public LootTable getLootTable() {
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
- return Bukkit.getLootTable(key);
+ if (this.getHandle().lootTable == null) {
+ this.getHandle().lootTable = this.getHandle().getDefaultLootTable();
+ }
+
+ // Scissors start - Return a null loot table if the specified loot table is not valid
+ try {
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
+ return Bukkit.getLootTable(key);
+ } catch (Exception ex) {
+ return null;
+ }
+ // Scissors end
}
@Override

View File

@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Sun, 20 Mar 2022 09:31:16 -0300
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 67feb4e688d049e9f74f0deabb1ec583336a29be..63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562 100644
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
@@ -314,7 +314,7 @@ public class HoverEvent {
CompoundTag compoundTag = TagParser.parseTag(string);
return new HoverEvent.ItemStackInfo(item, i, compoundTag);
} catch (CommandSyntaxException var6) {
- HoverEvent.LOGGER.warn("Failed to parse tag: {}", string, var6);
+ // Scissors - Ignore invalid items
}
}
@@ -328,7 +328,7 @@ public class HoverEvent {
CompoundTag compoundTag = TagParser.parseTag(text.getString());
return new HoverEvent.ItemStackInfo(ItemStack.of(compoundTag));
} catch (CommandSyntaxException var2) {
- HoverEvent.LOGGER.warn("Failed to parse item tag: {}", text, var2);
+ // Scissors - Ignore invalid items
return null;
}
}
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 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
@@ -396,7 +396,7 @@ public class ItemFrame extends HangingEntity {
ItemStack itemstack = ItemStack.of(nbttagcompound1);
if (itemstack.isEmpty()) {
- ItemFrame.LOGGER.warn("Unable to load item from: {}", nbttagcompound1);
+ // Scissors - ignore invalid items
}
ItemStack itemstack1 = this.getItem();

View File

@ -1,54 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 01:19:49 -0500
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 2481c50d8eb58a003e30e2d957b877bce5123a3a..6b284666eae8b7e0ef8f54dfe9311a0979b420fe 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 setPotionType(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 79abd84696ef099f6b12ddeaa6e398f18c53316a..7070b64c0c66b5c9d09bf7764ce506f4461dbac5 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -514,7 +514,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
});
}
@@ -538,7 +538,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 e3227a806d9e19923783122ea94ae19e7dbe71da..473dba5213f6aed7573e970119f4b6ad0e4f6367 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -572,7 +572,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");
}

View File

@ -1,73 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 26 Mar 2022 21:51:07 -0500
Subject: [PATCH] Change version fetcher to AMG
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
index ece77f5ea4b14bbed7c070131b3251ea86764538..f92610edcfb724374c69e66443eab60919ee955a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -4,6 +4,8 @@ import com.destroystokyo.paper.util.VersionFetcher;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.*;
+import io.papermc.paper.util.JarManifests;
+import java.util.Map;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport;
public class PaperVersionFetcher implements VersionFetcher {
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
- private static final String GITHUB_BRANCH_NAME = "master";
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
+ private static final String GITHUB_BRANCH_NAME = getBranch();
+ private static final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/Scissors/job/" + GITHUB_BRANCH_NAME;
private static @Nullable String mcVer;
@Override
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
@Nonnull
@Override
public Component getVersionMessage(@Nonnull String serverVersion) {
- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]");
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]);
final Component history = getHistory();
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
@@ -54,15 +56,24 @@ public class PaperVersionFetcher implements VersionFetcher {
return mcVer;
}
+ // Scissors start - Allow getting git information
+ public static String getCommit() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Commit");
+ }
+
+ public static String getBranch() {
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
+ return attributes.get("Git-Branch");
+ }
+ // Scissors end
+
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
int distance;
- try {
- int jenkinsBuild = Integer.parseInt(versionInfo);
- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
- } catch (NumberFormatException ignored) {
- versionInfo = versionInfo.replace("\"", "");
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
- }
+ // Scissors start - always use Git for version checking
+ versionInfo = getCommit();
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
+ // Scissors end
switch (distance) {
case -1:

View File

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Wed, 30 Mar 2022 18:20:09 -0600
Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
to CraftMetaItems
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 65844bb02bd3d9ef566d4779106a1f9ef2a2b7bc..f856ac2dfe55a1f1f63725ec20e7b8dd3d394acf 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -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.lang.Validate;
import org.apache.commons.lang3.EnumUtils;
@@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
- if (attributeName == null || attributeName.isEmpty()) {
+ if (attributeName == null || attributeName.isEmpty() || attributeName.length() < 256 || !ResourceLocation.isValidResourceLocation(attributeName)) { // Scissors
continue;
}

View File

@ -1,25 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Wed, 30 Mar 2022 02:01:55 -0600
Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile
conversion process
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index 9ec5bc2c29fc98ac2fbf9ff6231e8c3215ff11a1..9ef6b0a861a2b0f6e6d54775c6b0496689d12d66 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -76,7 +76,12 @@ public final class NbtUtils {
}
// Paper start - support string UUID's
if (compound.contains("Id", 8)) {
- uUID = UUID.fromString(compound.getString("Id"));
+ // Scissors start - Validate String UUIDs in game profiles
+ try {
+ uUID = UUID.fromString(compound.getString("Id"));
+ } catch (Exception ignored) {
+ }
+ // Scissors end
}
// Paper end

View File

@ -1,27 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sat, 9 Apr 2022 13:00:27 -0600
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 8e658eeb4edc83db72c187baa52b7ada7b848af8..e3dc56de3f91e03b1543257f72448a734d914ed7 100644
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
@@ -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.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);
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
+ return list.stream().filter((entity) -> !(entity instanceof Player)).map(NbtPredicate::getEntityTagToCompare); // Scissors - Don't query NBT from players
} else {
return Stream.empty();
}

View File

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 8 Apr 2022 23:38:12 -0300
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 ea68b26e506e48d8238b7ee4266e61b211d52bd2..10d3a1b31233f884823ee9a4bb27d70eac3914df 100644
--- a/src/main/java/net/minecraft/nbt/ListTag.java
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
@@ -33,6 +33,7 @@ public class ListTag extends CollectionTag<Tag> {
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
}
+ if(j > 1024) return new ListTag(Lists.newArrayListWithCapacity(0), b);
return new ListTag(list, b);
}
}

View File

@ -1,24 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Raneri <kevin.raneri@gmail.com>
Date: Sat, 2 Apr 2022 02:12:13 -0400
Subject: [PATCH] Fix lectern quick move
diff --git a/src/main/java/net/minecraft/world/inventory/LecternMenu.java b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
index ff79925bc6437222f9ceb133e21bbc0600cc74ed..e5498a5703f282160b8171a0b81711cfc24d323a 100644
--- a/src/main/java/net/minecraft/world/inventory/LecternMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
@@ -120,6 +120,13 @@ public class LecternMenu extends AbstractContainerMenu {
}
}
+ // Paper start
+ @Override
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int index) {
+ return ItemStack.EMPTY;
+ }
+ // Paper end
+
@Override
public void setData(int id, int value) {
super.setData(id, value);

View File

@ -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 {

View File

@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 01:24:05 -0500
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 901fa17d0f0a3f66923f68f13f183bc4c17f7748..dc9199c0b1fa9b8779afc51d7af4c516d217ddb3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2991,20 +2991,25 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
if (this.player.gameMode.isCreative()) {
boolean flag = packet.getSlotNum() < 0;
ItemStack itemstack = packet.getItem();
- CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
+ CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
// Paper start
- BlockEntity tileentity = null;
+ // 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 = null;
if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.getLevel().isLoadedAndInBounds(blockposition)) {
tileentity = this.player.level.getBlockEntity(blockposition);
}
// Paper end
- if (tileentity != null) {
- tileentity.saveToItem(itemstack);
+ if (tileentity != null) {
+ tileentity.saveToItem(
+ itemstack);
+ }
}
+ // Scissors end
}
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;

View File

@ -1,199 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 01:26:55 -0500
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 984105c226f16746b43bb2d2932e0b87f3a6a70c..faa41d102c06b52bc758ebe3484820376c482093 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 63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562..21ee39172b3efb6414d1cf8fbf36cd463194abab 100644
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
@@ -79,7 +79,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;
}
}
@@ -94,7 +94,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) -> {
@@ -182,7 +182,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);
}
}
@@ -191,7 +191,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 e3dc56de3f91e03b1543257f72448a734d914ed7..f518e47818a47be0dfd7cccc4845ba9736c6cd8b 100644
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
@@ -78,13 +78,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(() -> {
@@ -95,7 +96,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 dfd1f37757af1bd808cc2e2d8bf97123adf638bb..876e8f83fab4e255959948e59cabf05478446e4d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2215,12 +2215,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
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 8d5c9813010a0256bd2712a1eabbc91f0f473a41..6ec48f834f5fef8678c690fd5d1ea530ebd2720f 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
@@ -402,7 +402,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 = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
+ 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 1eccf9424bd8a4bcbeed4ebb1795fd113fe5af18..fcc3d2fbc679fdb70da27d20d19380fa238ba7ea 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
@@ -43,7 +43,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
public void load(CompoundTag nbt) {
super.load(nbt);
if (nbt.contains("CustomName", 8)) {
- this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
+ 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 0efb63d1a4cefede25712daf9cea0f5c3256980f..07fe4043184eda6fa11e0680930100eb914f64c1 100644
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
@@ -35,7 +35,7 @@ public class ScoreboardSaveData extends SavedData {
CompoundTag compoundTag = nbt.getCompound(i);
String string = compoundTag.getString("Name");
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);
}
@@ -53,14 +53,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);
}
@@ -115,7 +115,7 @@ public class ScoreboardSaveData extends SavedData {
CompoundTag compoundTag = nbt.getCompound(i);
ObjectiveCriteria.byName(compoundTag.getString("CriteriaName")).ifPresent((criterion) -> {
String string = compoundTag.getString("Name");
- 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, criterion, component, renderType);
});

View File

@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 11 Apr 2022 13:33:52 -0600
Subject: [PATCH] Fixes creative-killing potion effects and certain potion
effect overflows
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
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 {
}
public void applyEffectTick(LivingEntity entity, int amplifier) {
+ boolean god = entity instanceof Player player && (player.isCreative() || player.isInvulnerable()); // Scissors
if (this == MobEffects.REGENERATION) {
if (entity.getHealth() < entity.getMaxHealth()) {
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
@@ -75,17 +76,31 @@ public class MobEffect {
// CraftBukkit end
}
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
- if (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm()) {
+ // Scissors start
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
entity.hurt(DamageSource.MAGIC, (float) (6 << amplifier));
}
+ // Scissors end
} else {
- entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit
+ // Scissors start
+ if (!god) {
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit
+ }
+ // Scissors end
}
}
public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
int j;
+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't.
+ if (target instanceof Player player && (player.isCreative() || player.isInvulnerable())) {
+ return;
+ }
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ // Scissors end
if ((this != MobEffects.HEAL || target.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !target.isInvertedHealAndHarm())) {
if ((this != MobEffects.HARM || target.isInvertedHealAndHarm()) && (this != MobEffects.HEAL || !target.isInvertedHealAndHarm())) {

View File

@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 3 Jun 2022 19:30:14 -0500
Subject: [PATCH] Fix negative death times
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index d6ef140bcc35b10f78f2ec2f10c8a153395fc9df..d8393887cc98930815864eca28b07ef89b26f39e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -620,7 +620,7 @@ public abstract class LivingEntity extends Entity {
protected void tickDeath() {
++this.deathTime;
- if (this.deathTime == 20 && !this.level.isClientSide()) {
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level.isClientSide()) {
this.level.broadcastEntityEvent(this, (byte) 60);
this.remove(Entity.RemovalReason.KILLED);
}

View File

@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 01:27:54 -0500
Subject: [PATCH] Update for 1.18.2
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
index f92610edcfb724374c69e66443eab60919ee955a..69cc277e4b737ff5a7424cd9afc5573e6eaec3d3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
@@ -18,6 +18,7 @@ import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.stream.StreamSupport;
+import org.bukkit.Bukkit;
public class PaperVersionFetcher implements VersionFetcher {
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
@@ -56,15 +57,14 @@ public class PaperVersionFetcher implements VersionFetcher {
return mcVer;
}
- // Scissors start - Allow getting git information
- public static String getCommit() {
- Map<String, String> attributes = JarManifests.MANIFEST_MAP;
- return attributes.get("Git-Commit");
+ // Scissors start - Allow getting Git information
+ private static String getCommit() {
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
}
-
- public static String getBranch() {
- Map<String, String> attributes = JarManifests.MANIFEST_MAP;
- return attributes.get("Git-Branch");
+ private static String getBranch() {
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
}
// Scissors end
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
index f518e47818a47be0dfd7cccc4845ba9736c6cd8b..218525ba1742d68cde10f6caf09ee30eb2d01d50 100644
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
@@ -96,6 +96,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
return stream.map((string) -> {
return new TextComponent(string);
}).reduce((accumulator, current) -> {
+ // Scissors - untested, likely needs fixing
return (TextComponent) accumulator.append(text).append(current);
}).orElseGet(() -> {
return new TextComponent("");

View File

@ -1,158 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 22 Apr 2022 01:56:03 -0500
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 6837c965592d4584cfc958a1008b98791a0fc780..0f7d7248be0aa99dd759d12ed956a98822a2749b 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;
@@ -8,13 +9,13 @@ import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.logging.LogUtils;
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;
@@ -50,11 +51,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;
@@ -75,8 +72,6 @@ import net.minecraft.world.level.block.Block;
import org.slf4j.Logger;
// CraftBukkit start
-import com.mojang.serialization.Dynamic;
-import java.util.List;
import java.util.Map;
import java.util.Objects;
import net.minecraft.server.MinecraftServer;
@@ -251,6 +246,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)) {
@@ -495,7 +497,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;
@@ -827,6 +833,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;
this.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 226d9ac01c601fc8954a88bea93a521cdce79eda..9bfa2deca1258dd9c294422a0ea032142cd11789 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 {

View File

@ -1,267 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Business Goose <arclicious@vivaldi.net>
Date: Sun, 1 May 2022 01:20:13 +0100
Subject: [PATCH] Account for items inside containers
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..ad3af6d90b68bc55c29243da8814516575299bf0 100644
--- a/src/main/java/net/minecraft/world/ContainerHelper.java
+++ b/src/main/java/net/minecraft/world/ContainerHelper.java
@@ -1,5 +1,6 @@
package net.minecraft.world;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import java.util.List;
import java.util.function.Predicate;
import net.minecraft.core.NonNullList;
@@ -22,10 +23,14 @@ public class ContainerHelper {
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
ListTag listTag = new ListTag();
+ // Scissors - Account for items inside containers
+ long total = 0;
for(int i = 0; i < stacks.size(); ++i) {
ItemStack itemStack = stacks.get(i);
+
if (!itemStack.isEmpty()) {
+ total += NbtUtility.getTagSize(itemStack.getTag());
CompoundTag compoundTag = new CompoundTag();
compoundTag.putByte("Slot", (byte)i);
itemStack.save(compoundTag);
@@ -33,7 +38,7 @@ public class ContainerHelper {
}
}
- if (!listTag.isEmpty() || setIfEmpty) {
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) {
nbt.put("Items", listTag);
}
@@ -42,11 +47,18 @@ public class ContainerHelper {
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
ListTag listTag = nbt.getList("Items", 10);
+ // Scissors - Account for items inside containers
+ long total = 0;
for(int i = 0; i < listTag.size(); ++i) {
CompoundTag compoundTag = listTag.getCompound(i);
int j = compoundTag.getByte("Slot") & 255;
if (j >= 0 && j < stacks.size()) {
+ total += NbtUtility.getTagSize(compoundTag);
+ if (total >= NbtUtility.MAXIMUM_SIZE) {
+ stacks.clear();
+ break;
+ }
stacks.set(j, ItemStack.of(compoundTag));
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index 888e1f2bc6ea4ddbbcc5466f177233f25b290459..0f19ef250a2f82e49730cb58ea43ee6bf407455a 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
@@ -211,6 +212,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
index 5a47d58071b83ea911e4cb5e1cc5468801ad0d55..c6f25cb62335fda65596ba3f4a55734a88b75bd4 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
@@ -35,6 +36,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@Override
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
index 5c0f1488c8a8100cd39a03adeccded9984722249..d1e1b29298e1e074df1966498d7f3c94b20c77f4 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import java.util.Arrays;
import java.util.Iterator;
import javax.annotation.Nullable;
@@ -72,6 +73,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
}
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
index e56f7d76b501dab7d549efd2fafd514a9625c24e..153c70defdd6c25203764035c97ed3d20bc9c17e 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
@@ -41,6 +42,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
index f74c5bb8e1ba42c77c59d481b871fd992483b128..10393d499fa6a5e36750ed9305d22454ef98e6cf 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
@@ -30,6 +31,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index d241b25acc223982109495542fd17e0fbdf53437..ab952ef090ca5183340b014e0aae3aef553a4803 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import java.util.Iterator;
import java.util.List;
import java.util.function.BooleanSupplier;
@@ -53,7 +54,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+
return this.items;
+
}
public void onOpen(CraftHumanEntity who) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
index b4d38a9aa8792e979c99bedc20906679ba7991c6..5bdff2d3b13b3dbd0f3f83d9ece5a42173fb7e6c 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.github.atlasmediagroup.scissors.NbtUtility;
import java.util.List;
import java.util.stream.IntStream;
import javax.annotation.Nullable;
@@ -252,7 +253,19 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@Override
protected NonNullList<ItemStack> getItems() {
+ // Scissors - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.itemStacks) {
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
+ }
+
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.itemStacks.clear();
+ }
+
return this.itemStacks;
+
}
@Override

View File

@ -1,109 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 1 May 2022 14:23:35 -0500
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
vehicles if they collide with more than 15 other entities
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 96a7bfd921e59f298f0ee502d356cc3552c30ce8..6c1a489f03ecd7dfef161822cf6910f6119c082b 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.Util;
@@ -106,6 +107,7 @@ public abstract class AbstractMinecart extends Entity {
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision
private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
public double maxSpeed = 0.4D;
// CraftBukkit end
@@ -422,8 +424,10 @@ public abstract class AbstractMinecart extends Entity {
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
- if (!list.isEmpty()) {
- for (int l = 0; l < list.size(); ++l) {
+ // Scissors - Add a collision debounce
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
+ for (int l = 0; l < Math.min(3, list.size()); ++l) {
Entity entity = (Entity) list.get(l);
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
@@ -450,6 +454,16 @@ public abstract class AbstractMinecart extends Entity {
entity.push(this);
}
}
+
+ // Scissors - Add a collision debounce
+ if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+
+ // Scissors - Delete entity if the collision amount is over 15
+ if (list.size() > 15) {
+ this.discard();
+ }
}
} else {
Iterator iterator = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index 0dbc85c450797d7384e641f80e1b1f8c56fd14fc..99e9867dfc0b3ba8b11dd95c264794f2f0079994 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.UnmodifiableIterator;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.core.BlockPos;
@@ -106,6 +107,7 @@ public class Boat extends Entity {
public double unoccupiedDeceleration = -1;
public boolean landBoats = false;
// CraftBukkit end
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
public Boat(EntityType<? extends Boat> type, Level world) {
super(type, world);
@@ -398,10 +400,12 @@ public class Boat extends Entity {
this.checkInsideBlocks();
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
- if (!list.isEmpty()) {
+ // Scissors - Add collision debounce
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
boolean flag = !this.level.isClientSide && !(this.getControllingPassenger() instanceof Player);
- for (int j = 0; j < list.size(); ++j) {
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
+ for (int j = 0; j < Math.min(3, list.size()); ++j) {
Entity entity = (Entity) list.get(j);
if (!entity.hasPassenger((Entity) this)) {
@@ -412,6 +416,16 @@ public class Boat extends Entity {
}
}
}
+
+ // Scissors - Add collision debounce
+ if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+
+ // Scissors - Delete entity if the collision amount is over 15
+ if (list.size() > 15) {
+ this.discard();
+ }
}
}

View File

@ -1,63 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Business Goose <arclicious@vivaldi.net>
Date: Sun, 1 May 2022 01:19:36 +0100
Subject: [PATCH] Make the maximum tag size a constant & add a method for
getting tag size
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
index 058203440fd071ce5edbe18391ea60f0a5fbee3a..978cb98c81195640fb3704d2077148f2be0dca36 100644
--- a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
@@ -1,17 +1,49 @@
package com.github.atlasmediagroup.scissors;
-import net.minecraft.nbt.CompoundTag;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import net.minecraft.nbt.*;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
public class NbtUtility
{
+ public static final long MAXIMUM_SIZE = (256 * 1024);
+
+ public static long getTagSize(@Nullable Tag tag, int depth) {
+ if(depth > 512) return 0;
+ if(tag == null) return 0;
+
+ long size = 0;
+
+ if(tag.getType() == CompoundTag.TYPE) {
+ CompoundTag compoundTag = (CompoundTag) tag;
+ for(String key : compoundTag.getAllKeys()) {
+ size += getTagSize(compoundTag.get(key), depth + 1);
+ }
+ } else if(tag.getType() == ListTag.TYPE) {
+ ListTag listTag = (ListTag) tag;
+ for (Tag tag1 : listTag) {
+ size += getTagSize(tag1, depth + 1);
+ }
+ } else {
+ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length;
+ }
+
+ return size;
+ }
+
+ public static long getTagSize(@Nullable CompoundTag tag) {
+ return getTagSize(tag, 0);
+ }
public static boolean isTooLarge(@Nullable CompoundTag tag)
{
if (tag == null) return false;
- return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024);
+ return getTagSize(tag) > MAXIMUM_SIZE;
}
public static class Item

View File

@ -1,21 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Tue, 17 May 2022 05:57:52 +0100
Subject: [PATCH] Don't log invalid teams to console
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index d8393887cc98930815864eca28b07ef89b26f39e..3b5c48bfb7e7bcd0be9ad6d0357213c7adde08ad 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -813,7 +813,9 @@ public abstract class LivingEntity extends Entity {
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
if (!flag) {
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
+ // Scissors start - Prevent log spam possible with this error message, easily provokable by players in creative.
+ // LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
+ // Scissors end
}
}

View File

@ -1,231 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 22 May 2022 21:15:51 -0500
Subject: [PATCH] Prevent crash paintings and similar entity OOB exploits
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/MathUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/MathUtility.java
new file mode 100644
index 0000000000000000000000000000000000000000..7965cf3abd02d415dd0e71a0de73987e5fdf11ec
--- /dev/null
+++ b/src/main/java/com/github/atlasmediagroup/scissors/MathUtility.java
@@ -0,0 +1,29 @@
+package com.github.atlasmediagroup.scissors;
+
+public class MathUtility
+{
+ public static int clampInt(int number, int minimum, int maximum)
+ {
+ return Math.min(Math.max(number, minimum), maximum);
+ }
+
+ public static long clampLong(long number, long minimum, long maximum)
+ {
+ return Math.min(Math.max(number, minimum), maximum);
+ }
+
+ public static double clampDouble(double number, double minimum, double maximum)
+ {
+ return Math.min(Math.max(number, minimum), maximum);
+ }
+
+ public static int safeDoubleToInt(double number)
+ {
+ return (int) clampDouble(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
+ }
+
+ public static int safeLongToInt(long number)
+ {
+ return (int) clampLong(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
+ }
+}
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
index 978cb98c81195640fb3704d2077148f2be0dca36..59a4ff3593e74f72c3843554c2e14b82912c0a54 100644
--- a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
@@ -1,13 +1,9 @@
package com.github.atlasmediagroup.scissors;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
import net.minecraft.nbt.*;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
-import java.util.List;
public class NbtUtility
{
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/PositionUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/PositionUtility.java
new file mode 100644
index 0000000000000000000000000000000000000000..fd22a200e070ca5a594802d2f201c6b27d6cddcf
--- /dev/null
+++ b/src/main/java/com/github/atlasmediagroup/scissors/PositionUtility.java
@@ -0,0 +1,83 @@
+package com.github.atlasmediagroup.scissors;
+
+import net.minecraft.core.BlockPos;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.border.WorldBorder;
+import net.minecraft.world.phys.Vec3;
+
+public class PositionUtility
+{
+ public static Vec3 getValidVec3(double x, double y, double z, Entity entity)
+ {
+ final Level level = entity.level;
+
+ try
+ {
+ if (level.isInWorldBounds(new BlockPos(Math.floor(MathUtility.safeDoubleToInt(x)), Math.floor(MathUtility.safeDoubleToInt(y)), Math.floor(MathUtility.safeDoubleToInt(z)))))
+ {
+ return new Vec3(x, y, z);
+ }
+ else
+ {
+ final WorldBorder worldBorder = level.getWorldBorder();
+
+ final double maxX = worldBorder.getMaxX();
+ final double maxY = level.getMaxBuildHeight();
+ final double maxZ = worldBorder.getMaxZ();
+
+ final double minX = worldBorder.getMinX();
+ final double minY = level.getMinBuildHeight();
+ final double minZ = worldBorder.getMinZ();
+
+ return new Vec3(MathUtility.clampDouble(x, minX, maxX), MathUtility.clampDouble(y, minY, maxY), MathUtility.clampDouble(z, minZ, maxZ));
+ }
+ }
+ catch (Exception e)
+ { // If we throw some sort of exception due to the position being crazy, catch it
+ return new Vec3(0, 0, 0);
+ }
+ }
+
+ public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity)
+ {
+ final BlockPos validBlockPos = getValidBlockPos(blockPos, entity);
+
+ return new Vec3(validBlockPos.getX(), validBlockPos.getY(), validBlockPos.getZ());
+ }
+
+ public static BlockPos getValidBlockPos(BlockPos blockPos, Entity entity)
+ {
+ final Level level = entity.level;
+
+ try
+ {
+ if (level.isInWorldBounds(blockPos))
+ {
+ return blockPos;
+ }
+ else
+ {
+ final int x = blockPos.getX();
+ final int y = blockPos.getY();
+ final int z = blockPos.getZ();
+
+ final WorldBorder worldBorder = level.getWorldBorder();
+
+ final int maxX = MathUtility.safeDoubleToInt(worldBorder.getMaxX());
+ final int maxY = level.getMaxBuildHeight();
+ final int maxZ = MathUtility.safeDoubleToInt(worldBorder.getMaxZ());
+
+ final int minX = MathUtility.safeDoubleToInt(worldBorder.getMinX());
+ final int minY = level.getMinBuildHeight();
+ final int minZ = MathUtility.safeDoubleToInt(worldBorder.getMinZ());
+
+ return new BlockPos(MathUtility.clampInt(x, minX, maxX), MathUtility.clampInt(y, minY, maxY), MathUtility.clampInt(z, minZ, maxZ));
+ }
+ }
+ catch (Exception e)
+ { // If we throw some sort of exception due to the position being crazy, catch it
+ return new BlockPos(0, 0, 0);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 876e8f83fab4e255959948e59cabf05478446e4d..886451893fbc30576249ca6816c2579127acfe06 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.entity;
+import com.github.atlasmediagroup.scissors.PositionUtility;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.Iterables;
@@ -1775,6 +1776,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public void moveTo(double x, double y, double z, float yaw, float pitch) {
+ // Scissors start - Reassign x, y & z to make sure entities can't move out of the world border
+ Vec3 vec3 = PositionUtility.getValidVec3(x, y, z, this);
+ x = vec3.x;
+ y = vec3.y;
+ z = vec3.z;
+ // Scissors end
+
// Paper - cancel entity velocity if teleported
if (!preserveMotion) {
this.deltaMovement = Vec3.ZERO;
@@ -3209,6 +3217,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@Nullable
public Entity teleportTo(ServerLevel worldserver, BlockPos location) {
+ // Scissors start - Reassign location to a safe value
+ location = PositionUtility.getValidBlockPos(location, this);
+ // Scissors end
+
// CraftBukkit end
// Paper start - fix bad state entities causing dupes
if (!isAlive() || !valid) {
@@ -4103,6 +4115,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setPosRaw(x, y, z, false);
}
public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
+ // Scissors start - Reassign x, y & z to prevent entities from moving outside the world border
+ Vec3 vec = PositionUtility.getValidVec3(x, y, z, this);
+ x = vec.x;
+ y = vec.y;
+ z = vec.z;
+ // Scissors end
+
// Paper start - block invalid positions
if (!checkPosition(this, x, y, z)) {
return;
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
index 2805ebfe4ffe769bcde778a1225b3101c91538d8..7c988395567c170d825af2bd99121f2d4d05cd8d 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
@@ -1,5 +1,6 @@
package net.minecraft.world.entity.decoration;
+import com.github.atlasmediagroup.scissors.PositionUtility;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
@@ -265,7 +266,9 @@ public abstract class HangingEntity extends Entity {
@Override
public void readAdditionalSaveData(CompoundTag nbt) {
- this.pos = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
+ // Scissors start - Stop this stupid bullshit
+ this.pos = PositionUtility.getValidBlockPos(new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ")), this);
+ // Scissors end
}
public abstract int getWidth();
@@ -292,7 +295,9 @@ public abstract class HangingEntity extends Entity {
@Override
public void setPos(double x, double y, double z) {
- this.pos = new BlockPos(x, y, z);
+ // Scissors start - Fix this stupid bullshit
+ this.pos = PositionUtility.getValidBlockPos(new BlockPos(x, y, z), this);
+ // Scissors end
this.recalculateBoundingBox();
this.hasImpulse = true;
}