Patches from Luna (#144)

This commit is contained in:
Telesphoreo 2023-10-15 17:45:13 -05:00 committed by GitHub
parent f7e1e35ffc
commit 343f0b78b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 224 additions and 323 deletions

View file

@ -8,14 +8,3 @@
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
## Used in Scissors 1.19
#minecraft net/minecraft/world/ContainerHelper
#minecraft net/minecraft/network/chat/contents/NbtContents
#minecraft net/minecraft/network/chat/ComponentUtils
#minecraft net/minecraft/network/chat/contents/EntityDataSource
## Used in Scissors 1.20.2
#minecraft net/minecraft/network/chat/HoverEvent
#minecraft net/minecraft/world/level/block/entity/DecoratedPotBlockEntity
#minecraft net/minecraft/advancements/critereon/MinMaxBounds

View file

@ -2,7 +2,7 @@ group=me.totalfreedom.scissors
version=1.20.2-R0.1-SNAPSHOT
mcVersion=1.20.2
paperRef=852c1c236d080d9fd907a5f4fd3e850437996aa2
paperRef=e57af7d01e509c747520cc1037169029256289bf
org.gradle.caching=true
org.gradle.parallel=true

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 53cc6befb752affcfec65e18365f6d369448d407..181f5aa262689617ff3ad766dae485c36b88c9aa 100644
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
@@ -57,6 +57,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
@@ -83,17 +84,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())) {
+ // Scissors end
entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier));
}
} 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,46 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 16:29:23 -0300
Subject: [PATCH] Limit map decorations
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b6a38b1458957bd444fea439fa81d2976ffb86e0 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
@@ -2,6 +2,7 @@ package net.minecraft.world.level.saveddata.maps;
import java.util.Objects;
import javax.annotation.Nullable;
+import net.minecraft.ChatFormatting; // Scissors
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
@@ -14,6 +15,11 @@ public class MapDecoration {
private final Component name;
public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration text length
+ if (text != null && text.getString().length() > 32) {
+ text = null;
+ }
+ // Scissors end
this.type = type;
this.x = x;
this.y = z;
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 3b12030b49b1c539684d75ca3896eb498400ef99..0d55d73bd31747ad9579aebbb77f315aa3dc2bc8 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -354,6 +354,11 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts
index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695c05c097e 100644
index a79461457ea19339f47572c70705d655ebc55276..1ac1484fa13e1aadf6dfc964e7797534e2231950 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
@ -23,7 +23,7 @@ index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -68,11 +72,19 @@ tasks.jar {
@@ -66,11 +70,19 @@ tasks.jar {
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
@ -45,7 +45,7 @@ index c187641f0ec6444a10e0e1583e1697d07e8f0267..9d13bd2d5cb152c6aa5834ad735d1695
"Implementation-Vendor" to date, // Paper
"Specification-Title" to "Bukkit",
"Specification-Version" to project.version,
@@ -156,7 +168,7 @@ fun TaskContainer.registerRunTask(
@@ -154,7 +166,7 @@ fun TaskContainer.registerRunTask(
name: String,
block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) {
@ -133,17 +133,3 @@ index 774556a62eb240da42e84db4502e2ed43495be17..741c76c4dfa0bb34cc23bd795c194bde
Properties properties = new Properties();
if (stream != null) {
diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java
index 4afaac5928e55e6ef233deb058150e2ec63162c4..c7201e0d1d8fe664b461b1d443c21782bdbfa63c 100644
--- a/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java
+++ b/src/test/java/org/bukkit/craftbukkit/legacy/PersistentDataContainerLegacyTest.java
@@ -49,7 +49,9 @@ public class PersistentDataContainerLegacyTest extends AbstractTestingBase {
assertEquals(Float.valueOf(Float.MAX_VALUE), pdc.get(this.key("float"), PersistentDataType.FLOAT), "legacy float was wrong");
assertEquals(Double.valueOf(Double.MAX_VALUE), pdc.get(this.key("double"), PersistentDataType.DOUBLE), "legacy double was wrong");
assertEquals("stringy", pdc.get(this.key("string_simple"), PersistentDataType.STRING), "legacy string-simple was wrong");
+ /* This test fails for some reason and I don't know why
assertEquals("What a fun complex string 🔥", pdc.get(this.key("string_complex"), PersistentDataType.STRING), "legacy string-complex was wrong");
+ */
assertArrayEquals(new byte[]{Byte.MIN_VALUE}, pdc.get(this.key("byte_array"), PersistentDataType.BYTE_ARRAY), "legacy byte array was wrong");

View file

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 24 Sep 2023 15:09:27 -0500
From: Video <videogamesm12@gmail.com>
Date: Sat, 12 Mar 2022 19:34:59 -0700
Subject: [PATCH] UUID validation

View file

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 24 Sep 2023 15:27:44 -0500
From: Video <videogamesm12@gmail.com>
Date: Sun, 13 Mar 2022 07:39:26 -0600
Subject: [PATCH] ResourceLocation validation
@ -109,19 +109,6 @@ index 0425151e688966442340ea1cf892aff34ffe0791..244b04e0020b1bd1e7be34a1b6266a8a
this.lootTableSeed = nbt.getLong("LootTableSeed");
return true;
} else {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
index 6f154e5c4321b761ffa210401885ee3a1dac351b..404585564325e2ec45fc17c5cca4be9356c50093 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
@@ -105,7 +105,7 @@ public class DecoratedPotBlockEntity extends BlockEntity {
return Items.BRICK;
} else {
Tag tag = list.get(index);
- return BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(tag.getAsString()));
+ return BuiltInRegistries.ITEM.get(ResourceLocation.tryParse(tag.getAsString())); // Scissors
}
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 081691f9710ff1115e4308f79ed49fbc38941193..c29dfd15e147d5c4d9c9584ff7803c2a52009f0d 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java

View file

@ -4,6 +4,24 @@ Date: Mon, 28 Mar 2022 13:19:43 -0600
Subject: [PATCH] Better handling of invalid JSON components
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
index d02546b18cb689724887b4e85e8d32a18828a4ad..f8ffd6a52ad8c13eb13f51afe3a864cd3595d7eb 100644
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
@@ -655,12 +655,6 @@ public final class MCUtil {
return null;
}
String string = compound.getString(key);
- try {
- return net.minecraft.network.chat.Component.Serializer.fromJson(string);
- } catch (com.google.gson.JsonParseException e) {
- org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
- }
-
- return null;
+ return net.minecraft.network.chat.Component.Serializer.fromJsonSafe(string);
}
}
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
index b540ce21c65ad52ad7e94d2ca2b3926c0875bee1..9cb6fa8e35c89f73e7c95dbe219a4bf6d00b60a9 100644
--- a/src/main/java/net/minecraft/network/chat/Component.java

View file

@ -5,12 +5,12 @@ Subject: [PATCH] Block server-side chunkbans
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc44995e877b2 100644
index 45b4f1c295eda2fcc5067a4b21de247218ef117f..f2e7585630ff724f966c7bcedc17e502d786870d 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -6,9 +6,17 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.papermc.paper.adventure.PaperAdventure; // Paper
@@ -7,8 +7,16 @@ import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import java.io.IOException;
+import java.util.Collections; // Scissors
+import net.minecraft.ChatFormatting; // Scissors
@ -19,7 +19,6 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449
+import net.minecraft.network.chat.Component; // Scissors
+import net.minecraft.network.chat.SignedMessageBody; // Scissors
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
+import net.minecraft.network.protocol.game.*; // Scissors
import net.minecraft.util.profiling.jfr.JvmProfiler;
+import net.minecraft.world.item.ItemStack; // Scissors
@ -27,20 +26,20 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
this.flow = side;
this.codecKey = protocolKey;
}
+ // Scissors start
+ private static int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) {
+ private int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) {
+ friendlyByteBuf.writeVarInt(i);
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get();
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
+
+ int j = friendlyByteBuf.writerIndex();
+ packet.write(friendlyByteBuf);
+ int k = friendlyByteBuf.writerIndex() - j;
+ int packetLength = friendlyByteBuf.readableBytes();
+ if (k > 8388608 || packetLength > MAX_PACKET_SIZE) {
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big (is " + k + "): " + packet));
+ if (packetLength > MAX_PACKET_SIZE) {
+ throw new PacketTooLargeException(packet, this.codecKey, packetLength);
+ }
+
+ return k;
@ -48,14 +47,14 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449
+ // Scissors end
+
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get();
if (connectionProtocol == null) {
@@ -33,38 +58,59 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
Attribute<ConnectionProtocol.CodecData<?>> attribute = channelHandlerContext.channel().attr(this.codecKey);
ConnectionProtocol.CodecData<?> codecData = attribute.get();
@@ -34,39 +59,59 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw new IOException("Can't serialize unregistered packet");
} else {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
- friendlyByteBuf.writeVarInt(i);
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
+ // Scissors start
+ int k;
@ -65,33 +64,34 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..7de21c9bcc1f3c556790da62f96cc449
- int k = friendlyByteBuf.writerIndex() - j;
- if (false && k > 8388608) { // Paper - disable
- throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
- } else {
- int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
- JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k);
- }
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
} catch (Throwable var10) {
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var10); // Paper - Give proper error message
-
- JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k);
+ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
} catch (Throwable var13) {
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var13); // Paper - Give proper error message
- if (packet.isSkippable()) {
- throw new SkipPacketException(var10);
- } else {
- throw var10;
- throw new SkipPacketException(var13);
+ packet = capPacket(packet, i);
+ if (packet == null) {
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
}
+ friendlyByteBuf.clear();
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
}
-
- throw var13;
- } finally {
- // Paper start
- int packetLength = friendlyByteBuf.readableBytes();
- if (packetLength > MAX_PACKET_SIZE) {
- throw new PacketTooLargeException(packet, packetLength);
- throw new PacketTooLargeException(packet, this.codecKey, packetLength);
- }
- // Paper end
+ int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
+ JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k);
- ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
+ friendlyByteBuf.clear();
+ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
}
+ JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k);
+ ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
+ // Scissors end
}
}
@ -146,7 +146,7 @@ index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f30
this.type = blockEntityType;
this.tag = nbt.isEmpty() ? null : nbt;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..688287c637a0d4b28d630b7304a3c2cf339bdf54 100644
index 51e24105facfe71ce9f2757c6c881a21b58dacfd..5692fbae221fb01d32d92edc7bea0f6312e24e1c 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData {

View file

@ -447,7 +447,7 @@ index dbccbcb9b44e4efacdf53c2d161115cc20b36cff..c3eb9eef724fa04ede965c5875b948c8
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
this.setMotd(dedicatedserverproperties.motd);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 5d8b8b17854c1ae2a5e2ccfb8df1d7b927191f03..f14def6e5923afa4880ef3e5626cc973d4b01e48 100644
index f7c3b65e0d6c76189aea00232b33722c4363d7dd..8b872a406752a72d49ff029e2586d4ac17d7be1f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1038,6 +1038,7 @@ public final class CraftServer implements Server {
@ -482,7 +482,7 @@ index 5d8b8b17854c1ae2a5e2ccfb8df1d7b927191f03..f14def6e5923afa4880ef3e5626cc973
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index e3c230fd2a054a8cb60328c9309410a2f53dad26..d2e06850ec9edadb76668e41403203c66731a961 100644
index ebec18e919885f9220693a8a419d239e8cddd567..544698c044d9eef57abccfbd41cbfdd6873e4f55 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -180,6 +180,20 @@ public class Main {

View file

@ -0,0 +1,34 @@
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/HealOrHarmMobEffect.java b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
index 1c7794de5f0a7238b944c9473e2cc9d011ef2306..9c594c504611b9da5fcd119284b2dcb4b59d3bf4 100644
--- a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
+++ b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
@@ -16,6 +16,11 @@ class HealOrHarmMobEffect extends InstantenousMobEffect {
@Override
public void applyEffectTick(LivingEntity entity, int amplifier) {
super.applyEffectTick(entity, amplifier);
+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't.
+ if (entity instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return;
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ // Scissors end
+
if (this.isHarm == entity.isInvertedHealAndHarm()) {
entity.heal((float) Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
} else {
@@ -27,6 +32,10 @@ class HealOrHarmMobEffect extends InstantenousMobEffect {
@Override
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 net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return;
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ // Scissors end
if (this.isHarm == target.isInvertedHealAndHarm()) {
j = (int) (proximity * (double) (4 << amplifier) + 0.5D);

View file

@ -5,7 +5,7 @@ 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 c039c77d0dd6ec1d336948ca6b5351d6fae1d8bb..6d851bf1cff06edf0717080c65a504c63914b8cd 100644
index b95f88d5e5b4785ee063695fd81935636a0588d1..168b002377e258f84a3bb86dd8e4a5f42060e3e0 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -629,7 +629,7 @@ public abstract class LivingEntity extends Entity implements Attackable {

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
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 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce032ece6b 100644
index 44a6118d3bd67a95180f750c17967561946e2e87..8aece67eba8d6b558bc2441b8b8e599f86e12e4f 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;
@ -17,7 +17,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.Util;
@@ -107,6 +108,7 @@ public abstract class AbstractMinecart extends Entity {
@@ -111,6 +112,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
@ -25,20 +25,18 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce
public double maxSpeed = 0.4D;
// CraftBukkit end
@@ -434,8 +436,10 @@ public abstract class AbstractMinecart extends Entity {
@@ -432,8 +434,8 @@ 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 start
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
+ for (int l = 0; l < Math.min(3, list.size()); ++l) {
+ // Scissors end
Entity entity = (Entity) list.get(l);
- Iterator iterator = list.iterator();
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
@@ -462,6 +466,14 @@ public abstract class AbstractMinecart extends Entity {
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -462,6 +464,14 @@ public abstract class AbstractMinecart extends Entity {
entity.push(this);
}
}
@ -52,9 +50,9 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce
+ // Scissors end
}
} else {
Iterator iterator = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
Iterator iterator1 = 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 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f87202907 100644
index 5c07da62c82bc70138f6cb5007629d6974be69ac..301a72dffd4ac58333d987e85d22136498d2d82a 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -5,6 +5,7 @@ import com.google.common.collect.UnmodifiableIterator;
@ -65,7 +63,7 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.core.BlockPos;
@@ -109,6 +110,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@@ -112,6 +113,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
public double unoccupiedDeceleration = -1;
public boolean landBoats = false;
// CraftBukkit end
@ -73,20 +71,19 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f
public Boat(EntityType<? extends Boat> type, Level world) {
super(type, world);
@@ -421,10 +423,10 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@@ -465,9 +467,9 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
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()) {
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player);
- Iterator iterator = list.iterator();
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
- for (int j = 0; j < list.size(); ++j) {
+ for (int j = 0; j < Math.min(3, list.size()); ++j) { // Scissors - Limit amount of vehicle collision checks to 3 maximum
Entity entity = (Entity) list.get(j);
if (!entity.hasPassenger((Entity) this)) {
@@ -435,6 +437,14 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -480,6 +482,14 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
}
}
}

View file

@ -59,7 +59,7 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..04c47cf1a920ae6c356449df801227ee
}
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 16f087adbf94b8fd6726ffd300b103dd709ad406..71c5d49bfe7c39c11f27e17b156dd4e6d0fef285 100644
index 4697df75fdee2023c41260bed211e3e3d90d2b9b..1ddf7ca63fee0849f3a41f230e0fd7ab636ff05c 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -21,6 +21,7 @@ import java.util.function.Predicate;

View file

@ -5,7 +5,7 @@ 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 6d851bf1cff06edf0717080c65a504c63914b8cd..93f3eab8008af9fa91dca88ebd2dfbdf27c8281a 100644
index 168b002377e258f84a3bb86dd8e4a5f42060e3e0..065d2c1543832190bd8bdcd4b553542115c07e64 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -861,7 +861,7 @@ public abstract class LivingEntity extends Entity implements Attackable {

View file

@ -1,21 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 24 Sep 2023 16:19:52 -0500
From: Allink <arclicious@vivaldi.net>
Date: Tue, 5 Jul 2022 04:12:31 +0100
Subject: [PATCH] Add spectator teleport event
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b5fe3786b337fb99920aac72b865e6a25bcb9649..8e1b95371ed0bac1a4fff2d6550de118ba399650 100644
index 34fcdeb0f4039f1fc6c4c8c593cc615560af1ba2..40166e794ad1f2d2555bd47a442771db5bee79f9 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -29,6 +29,7 @@ import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
@@ -1,5 +1,6 @@
package net.minecraft.server.network;
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
import com.mojang.authlib.GameProfile;
@@ -2005,6 +2006,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Entity entity = packet.getEntity(worldserver);

View file

@ -5,13 +5,13 @@ Subject: [PATCH] Prevent invalid container events
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 8e1b95371ed0bac1a4fff2d6550de118ba399650..e6d7b277b3b305d5069c73d9107c20ff11e34b7c 100644
index 40166e794ad1f2d2555bd47a442771db5bee79f9..0c878b99574b0e27f1463069f66d24bdecb01647 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -30,6 +30,7 @@ import java.util.stream.Collectors;
@@ -30,6 +30,7 @@ import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
+import net.kyori.adventure.text.format.NamedTextColor; // Scissors
import net.minecraft.ChatFormatting;
import net.minecraft.SharedConstants;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Validate block entity/entity tag query positions
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index e6d7b277b3b305d5069c73d9107c20ff11e34b7c..001b7ae2067809d7da1d84d7637639f21a1aa980 100644
index 0c878b99574b0e27f1463069f66d24bdecb01647..51331ad3f295b55631adcb6f47e34d0b03bd148a 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1261,7 +1261,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl

View file

@ -60,18 +60,17 @@ index c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d281cc64c9 100644
index 51331ad3f295b55631adcb6f47e34d0b03bd148a..19f573a1f62280bd9b67a4027962fcb7de6d2514 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1,5 +1,7 @@
@@ -1,5 +1,6 @@
package net.minecraft.server.network;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
import com.mojang.authlib.GameProfile;
@@ -2219,7 +2221,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2219,7 +2220,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
@ -80,7 +79,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
} else {
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
@@ -2275,6 +2277,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2275,6 +2276,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
if (optional.isEmpty()) {
@ -88,7 +87,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
}
@@ -2483,6 +2486,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2483,6 +2485,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
@ -96,7 +95,7 @@ index 001b7ae2067809d7da1d84d7637639f21a1aa980..ad87d90de1679955cb5a9d1c925be7d2
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
}
@@ -3456,6 +3460,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3455,6 +3458,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@Override
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());

View file

@ -1,37 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Mon, 25 Sep 2023 18:58:34 -0500
From: Luna <lunahatesgogle@gmail.com>
Date: Sun, 2 Apr 2023 16:29:51 -0300
Subject: [PATCH] Patch large selector distance crash
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
index 8897496323378080135127f53db004d576476c21..a4de9cfcbe7d7d6b05feb3a6be683437e9b00c2b 100644
index 8897496323378080135127f53db004d576476c21..5f957d3241c1931f8166bc9e4960cef15679e932 100644
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
@@ -131,7 +131,7 @@ public interface MinMaxBounds<T extends Number> {
@@ -129,9 +129,9 @@ public interface MinMaxBounds<T extends Number> {
public static record Doubles(Optional<Double> min, Optional<Double> max, Optional<Double> minSq, Optional<Double> maxSq) implements MinMaxBounds<Double> {
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
- public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
+ public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.<Double, MinMaxBounds.Doubles>createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes
- private Doubles(Optional<Double> optional, Optional<Double> optional2) {
+ public Doubles(Optional<Double> optional, Optional<Double> optional2) { // Scissors - private -> public
this(optional, optional2, squareOpt(optional), squareOpt(optional2));
}
@@ -202,7 +202,7 @@ public interface MinMaxBounds<T extends Number> {
public static record Ints(Optional<Integer> min, Optional<Integer> max, Optional<Long> minSq, Optional<Long> maxSq) implements MinMaxBounds<Integer> {
public static final MinMaxBounds.Ints ANY = new MinMaxBounds.Ints(Optional.empty(), Optional.empty());
- public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new);
+ public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.<Integer, MinMaxBounds.Ints>createCodec(Codec.INT, MinMaxBounds.Ints::new); // Scissors - compile fixes
private Ints(Optional<Integer> optional, Optional<Integer> optional2) {
this(optional, optional2, optional.map((integer) -> {
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..0ea61a4c58bd6d126aff9872ba9c4dc27fb7c099 100644
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..6cb3e86f2d661a55536b782729f768ef72163223 100644
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
@@ -5,11 +5,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
+import java.util.Optional; // Scissors
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.MathUtility;
+import me.totalfreedom.scissors.MathUtility; // Scissors
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityArgument;
@ -42,8 +54,8 @@ index 73c15a0c56a103ba4e62f0a51af8d42566b07245..0ea61a4c58bd6d126aff9872ba9c4dc2
- this.range = distance;
+ // Scissors start - Patch large selector distance crash
+ this.range = new MinMaxBounds.Doubles(
+ Optional.of(distance.min().get() != null ? Math.min(distance.min().get(), 1024) : null),
+ Optional.of(distance.max().get() != null ? Math.min(distance.max().get(), 1024) : null)
+ distance.min().map(min -> Math.min(min, 1024)),
+ distance.max().map(max -> Math.min(max, 1024))
+ );
this.position = positionOffset;
- this.aabb = box;

View file

@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 16:29:23 -0300
Subject: [PATCH] Limit map decorations
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
index 81f3e64d94fa17e45411e5c1641d9c5a2fe3d2e2..bcf6e2ce9f00d1688a5fa00ec055a57389346922 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
@@ -65,7 +65,8 @@ public class ClientboundMapItemDataPacket implements Packet<ClientGamePacketList
b.writeByte(icon.x());
b.writeByte(icon.y());
b.writeByte(icon.rot() & 15);
- b.writeNullable(icon.name(), FriendlyByteBuf::writeComponent);
+ final boolean passedNameCap = icon.name() == null || icon.name().getString().length() <= 32; // Scissors
+ b.writeNullable(passedNameCap ? icon.name() : null, FriendlyByteBuf::writeComponent); // Scissors
});
});
if (this.colorPatch != null) {
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index e4c4948e076cd64686dfd16ae0568fafc1437140..eff53c21b18574750b691b784fb1688885d4ace7 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -361,6 +361,11 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;

View file

@ -1,48 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 30 Sep 2023 18:41:40 -0500
Subject: [PATCH] Limit map decorations
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index e4c4948e076cd64686dfd16ae0568fafc1437140..eff53c21b18574750b691b784fb1688885d4ace7 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -361,6 +361,11 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;
diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
index 2d2bf5c37709b8e747fbfa2db5ce86f258e86224..eeffb546dfa6a094089d322e46e44a8a69238680 100644
--- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
+++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.map;
+import net.minecraft.network.chat.Component;
import net.minecraft.world.level.saveddata.maps.MapDecoration;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import org.bukkit.Bukkit;
@@ -42,7 +43,13 @@ public class CraftMapRenderer extends MapRenderer {
}
MapDecoration decoration = worldMap.decorations.get(key);
- cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, decoration.name() == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(decoration.name())); // Paper
+ // Scissors start - Limit decoration text length
+ Component name = decoration.name();
+ if (decoration.name() != null && decoration.name().getString().length() > 32) {
+ name = null;
+ }
+ cursors.addCursor(decoration.x(), decoration.y(), (byte) (decoration.rot() & 15), decoration.type().getIcon(), true, name == null ? null : io.papermc.paper.adventure.PaperAdventure.asAdventure(decoration.name())); // Paper
+ // Scissors end
}
}

View file

@ -18,7 +18,7 @@ index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400
private final boolean trackOutput;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bda200bd63 100644
index 19f573a1f62280bd9b67a4027962fcb7de6d2514..f5cdac55c8cbe334b96c5a0b2c34f216109120d3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1,6 +1,8 @@
@ -30,7 +30,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
@@ -155,6 +157,7 @@ import net.minecraft.world.entity.player.Inventory;
@@ -154,6 +156,7 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.vehicle.Boat;
@ -38,7 +38,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
@@ -182,6 +185,8 @@ import net.minecraft.world.phys.Vec3;
@@ -181,6 +184,8 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
@ -47,7 +47,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd
import org.slf4j.Logger;
// CraftBukkit start
@@ -893,6 +898,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -892,6 +897,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
}
@ -64,7 +64,7 @@ index ad87d90de1679955cb5a9d1c925be7d281cc64c9..b4213a2f0f8c57b606b1a1a993d352bd
commandblocklistenerabstract.setCommand(s);
commandblocklistenerabstract.setTrackOutput(flag);
if (!flag) {
@@ -924,7 +939,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -923,7 +938,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
if (commandblocklistenerabstract != null) {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Fix packet-related lag exploits
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c4012333a3e4 100644
index f5cdac55c8cbe334b96c5a0b2c34f216109120d3..78f9e0587f35ed8034fd2c275e0e06abae90e0e6 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -858,7 +858,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -857,7 +857,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
} else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
@ -17,7 +17,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401
BaseCommandBlock commandblocklistenerabstract = null;
CommandBlockEntity tileentitycommand = null;
BlockPos blockposition = packet.getPos();
@@ -1025,7 +1025,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1024,7 +1024,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@Override
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -26,7 +26,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401
BlockPos blockposition = packet.getPos();
BlockState iblockdata = this.player.level().getBlockState(blockposition);
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
@@ -1083,7 +1083,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1082,7 +1082,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@Override
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -35,7 +35,7 @@ index 4d225bb5126c083e0bf7f98992cd6d63c2dd44e9..73f6423b96ffa392e390df269f94c401
BlockPos blockposition = packet.getPos();
BlockState iblockdata = this.player.level().getBlockState(blockposition);
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
@@ -1106,7 +1106,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1105,7 +1105,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@Override
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Limit save data for Bees and Vexes
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
index 55026e1731e41b4e3e4c6a8fef5d96a32051a556..4a8383d48da4fcf39ec528a00cd09417f8d08c57 100644
index 9a7956befc346e1b58f064213800fd099a052fc6..2ebedd806bafc6ff7c4bf5a962ead50ce2ad1a8a 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
@@ -227,8 +227,12 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {

View file

@ -6,23 +6,11 @@ Subject: [PATCH] Don't return null Components in the Component codec
Found by Sk8kman
diff --git a/src/main/java/net/minecraft/util/ExtraCodecs.java b/src/main/java/net/minecraft/util/ExtraCodecs.java
index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee918fc27e2 100644
index 607f32b856c6c1fb81d3f1604f3bf3fb240d713f..5afdc9d93e696568cc8a263ab0142fbac258e874 100644
--- a/src/main/java/net/minecraft/util/ExtraCodecs.java
+++ b/src/main/java/net/minecraft/util/ExtraCodecs.java
@@ -62,7 +62,10 @@ public class ExtraCodecs {
});
public static final Codec<Component> COMPONENT = JSON.flatXmap((element) -> {
try {
- return DataResult.success(Component.Serializer.fromJson(element));
+ // Scissors start
+ final Component component = Component.Serializer.fromJson(element);
+ return DataResult.success(component != null ? component : Component.empty());
+ // Scissors end
} catch (JsonParseException var2) {
return DataResult.error(var2::getMessage);
}
@@ -75,7 +78,10 @@ public class ExtraCodecs {
});
@@ -70,7 +70,10 @@ public class ExtraCodecs {
public static final Codec<Component> COMPONENT = adaptJsonSerializer(Component.Serializer::fromJson, Component.Serializer::toJsonTree);
public static final Codec<Component> FLAT_COMPONENT = Codec.STRING.flatXmap((json) -> {
try {
- return DataResult.success(Component.Serializer.fromJson(json));
@ -33,7 +21,19 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9
} catch (JsonParseException var2) {
return DataResult.error(var2::getMessage);
}
@@ -246,7 +252,7 @@ public class ExtraCodecs {
@@ -233,7 +236,10 @@ public class ExtraCodecs {
public static <T> Codec<T> adaptJsonSerializer(Function<JsonElement, T> deserializer, Function<T, JsonElement> serializer) {
return JSON.flatXmap((json) -> {
try {
- return DataResult.success(deserializer.apply(json));
+ // Scissors start
+ final T value = deserializer.apply(json);
+ return DataResult.success(value != null ? value : (T)Component.empty());
+ // Scissors end
} catch (JsonParseException var3) {
return DataResult.error(var3::getMessage);
}
@@ -260,7 +266,7 @@ public class ExtraCodecs {
}, (pair) -> {
return ImmutableList.of(leftFunction.apply(pair), rightFunction.apply(pair));
});
@ -42,7 +42,7 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9
return instance.group(codec.fieldOf(leftFieldName).forGetter(Pair::getFirst), codec.fieldOf(rightFieldName).forGetter(Pair::getSecond)).apply(instance, Pair::of);
}).comapFlatMap((pair) -> {
return combineFunction.apply((P)pair.getFirst(), (P)pair.getSecond());
@@ -278,7 +284,7 @@ public class ExtraCodecs {
@@ -286,7 +292,7 @@ public class ExtraCodecs {
Optional<Pair<A, T>> optional = dataResult.resultOrPartial(mutableObject::setValue);
return optional.isPresent() ? dataResult : DataResult.error(() -> {
return "(" + (String)mutableObject.getValue() + " -> using default)";
@ -51,12 +51,3 @@ index 066d423dc908080157586555ba01053a2477d570..aa6e5de37ce69c9bc6b8e1e0b5ab0ee9
}
public <T> DataResult<T> coApply(DynamicOps<T> dynamicOps, A objectx, DataResult<T> dataResult) {
@@ -565,7 +571,7 @@ public class ExtraCodecs {
static record LazyInitializedCodec<A>(Supplier<Codec<A>> delegate) implements Codec<A> {
LazyInitializedCodec {
- supplier = Suppliers.memoize(supplier::get);
+ delegate = Suppliers.memoize(delegate::get); // Scissors - Decompile error
}
public <T> DataResult<Pair<A, T>> decode(DynamicOps<T> dynamicOps, T object) {