Scissors/patches/server/0039-Limit-map-decorations.patch
Luna 2109ba025d
Fix unused patches (#115)
* Remove patch that is now in Paper

* Redirect Paper's safe component method to ours
2023-07-04 11:49:28 -05:00

47 lines
2.3 KiB
Diff

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;