These go in

This commit is contained in:
Telesphoreo 2022-06-10 23:28:30 -05:00
parent d6ac0443f0
commit 08bd23459f
7 changed files with 207 additions and 0 deletions

View file

@ -0,0 +1,32 @@
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 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f2942799715 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;
@@ -370,6 +371,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

@ -0,0 +1,31 @@
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

@ -0,0 +1,23 @@
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

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Fri, 10 Jun 2022 23:26:03 -0500
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 3c4dadd0012c11191c873fe25a7625193563915d..d8eb84f28761dce95330afc32e4c011a4ab89b18 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1792,8 +1792,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

@ -0,0 +1,25 @@
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

@ -0,0 +1,26 @@
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

@ -0,0 +1,50 @@
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
}
}
}