-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
From 4adef32d2418f5c1e1891346b655557e5850790e Mon Sep 17 00:00:00 2001 | ||
From 04c6b026af4aad5996388baee237f473969290cb Mon Sep 17 00:00:00 2001 | ||
From: Samsuik <[email protected]> | ||
Date: Tue, 9 May 2023 16:43:24 +0100 | ||
Subject: [PATCH] Fix some creative exploits | ||
|
@@ -260,6 +260,56 @@ index 863e9d8e9..0b3fe9930 100644 | |
entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit | ||
} | ||
|
||
diff --git a/src/main/java/net/minecraft/server/TileEntityBanner.java b/src/main/java/net/minecraft/server/TileEntityBanner.java | ||
index aa5ad2ef0..8778e1ce9 100644 | ||
--- a/src/main/java/net/minecraft/server/TileEntityBanner.java | ||
+++ b/src/main/java/net/minecraft/server/TileEntityBanner.java | ||
@@ -19,11 +19,7 @@ public class TileEntityBanner extends TileEntity { | ||
NBTTagCompound nbttagcompound = itemstack.getTag().getCompound("BlockEntityTag"); | ||
|
||
if (nbttagcompound.hasKey("Patterns")) { | ||
- this.patterns = (NBTTagList) nbttagcompound.getList("Patterns", 10).clone(); | ||
- // CraftBukkit start | ||
- while (this.patterns.size() > 20) { | ||
- this.patterns.a(20); // PAIL Rename remove | ||
- } | ||
+ this.patterns = loadPatternsFromCompound(nbttagcompound); // Blossom - avoid o(n^2) removal of unnecessary patterns | ||
// CraftBukkit end | ||
} | ||
|
||
@@ -42,6 +38,18 @@ public class TileEntityBanner extends TileEntity { | ||
this.g = true; | ||
} | ||
|
||
+ // Blossom start | ||
+ private NBTTagList loadPatternsFromCompound(NBTTagCompound nbttagcompound) { | ||
+ NBTTagList list = nbttagcompound.getList("Patterns", 10); | ||
+ NBTTagList patterns = new NBTTagList(); | ||
+ int min = Math.min(list.size(), 20); | ||
+ for (int i = 0; i < min; ++i) { | ||
+ patterns.add(list.get(i)); | ||
+ } | ||
+ return patterns; | ||
+ } | ||
+ // Blossom end | ||
+ | ||
public void b(NBTTagCompound nbttagcompound) { | ||
super.b(nbttagcompound); | ||
a(nbttagcompound, this.color, this.patterns); | ||
@@ -58,12 +66,7 @@ public class TileEntityBanner extends TileEntity { | ||
public void a(NBTTagCompound nbttagcompound) { | ||
super.a(nbttagcompound); | ||
this.color = nbttagcompound.getInt("Base"); | ||
- this.patterns = nbttagcompound.getList("Patterns", 10); | ||
- // CraftBukkit start | ||
- while (this.patterns.size() > 20) { | ||
- this.patterns.a(20); // PAIL Rename remove | ||
- } | ||
- // CraftBukkit end | ||
+ this.patterns = loadPatternsFromCompound(nbttagcompound); // Blossom - avoid o(n^2) removal of unnecessary patterns | ||
this.h = null; | ||
this.i = null; | ||
this.j = null; | ||
diff --git a/src/main/java/net/minecraft/server/TileEntitySkull.java b/src/main/java/net/minecraft/server/TileEntitySkull.java | ||
index 58014c5f1..51b7cc90a 100644 | ||
--- a/src/main/java/net/minecraft/server/TileEntitySkull.java | ||
|