mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-06-27 16:06:40 +00:00
everything that went in cleanly
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 10 Apr 2023 13:56:18 -0300
|
||||
Subject: [PATCH] Limit sculk catalyst cursor positions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
index de90a216321f7d82310a0d1c915fefe64360534c..7e52f6c26234cf6fa092151d51c0c6b70dc22ca8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
@@ -181,7 +181,7 @@ public class SculkSpreader {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
SculkSpreader.ChargeCursor sculkspreader_a = (SculkSpreader.ChargeCursor) iterator.next();
|
||||
-
|
||||
+ if (!world.getMinecraftWorld().isLoadedAndInBounds(sculkspreader_a.getPos())) continue; // Scissors
|
||||
sculkspreader_a.update(world, pos, random, this, shouldConvertToBlock);
|
||||
if (sculkspreader_a.charge <= 0) {
|
||||
world.levelEvent(3006, sculkspreader_a.getPos(), 0);
|
@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:44:50 -0300
|
||||
Subject: [PATCH] Prevent player banning using duplicate UUIDs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 18aac3da3c88f33b1a71a5920a8daa27e9723913..b1bfb12f10d6fec9ca905498b4a6768997867311 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1610,7 +1610,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (entity != null) {
|
||||
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID().toString());
|
||||
entity.unRide();
|
||||
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
|
||||
+ // Scissors start - Prevent player banning using duplicate UUIDs
|
||||
+ if (entity instanceof ServerPlayer serverPlayer) {
|
||||
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
|
||||
+ } else {
|
||||
+ entity.discard();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:46:00 -0300
|
||||
Subject: [PATCH] Don't warn on duplicate entity UUIDs
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
index 41791c7331c80d496cde4e3d1846a178bef0bbe3..d04181bda85dbaa77d3b55b04b25519496bec4ff 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
@@ -372,7 +372,7 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
|
||||
return false;
|
||||
}
|
||||
if (this.entityByUUID.containsKey(entity.getUUID())) {
|
||||
- LOGGER.warn("Entity uuid already exists: " + entity.getUUID() + ", mapped to " + this.entityByUUID.get(entity.getUUID()) + ", can't add " + entity);
|
||||
+ // Scissors - Don't warn on duplicate entity UUIDs
|
||||
return false;
|
||||
}
|
||||
this.entityById.put(entity.getId(), entity);
|
@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 29 May 2023 19:34:50 -0300
|
||||
Subject: [PATCH] Fix component extra empty array exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index 2873ed7c443ed8c8c57a8b1d3e444d229f10f07b..a2149452ee461002ea74189c5aa49cddd943d0cf 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -266,6 +266,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
if (!jsonelement.isJsonObject()) {
|
||||
if (jsonelement.isJsonArray()) {
|
||||
JsonArray jsonarray = jsonelement.getAsJsonArray();
|
||||
+ if (jsonarray.size() <= 0) throw new JsonParseException("Unexpected empty array of components"); // Scissors
|
||||
|
||||
ichatmutablecomponent = null;
|
||||
Iterator iterator = jsonarray.iterator();
|
@ -0,0 +1,125 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Wed, 31 May 2023 18:14:00 -0300
|
||||
Subject: [PATCH] Add depth limit to Component deserializer
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index a2149452ee461002ea74189c5aa49cddd943d0cf..f1d1501211a923c0ccab6b5982887c3a9262889b 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.ChatFormatting; // Scissors
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
||||
@@ -44,6 +45,7 @@ import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
|
||||
// CraftBukkit start
|
||||
import com.google.common.collect.Streams;
|
||||
+import java.util.regex.Pattern; // Scissors
|
||||
import java.util.stream.Stream;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -254,10 +256,16 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
throw new IllegalStateException("Couldn't get field 'lineStart' for JsonReader", nosuchfieldexception);
|
||||
}
|
||||
});
|
||||
+ private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("%[0-9]+\\$s"); // Scissors
|
||||
|
||||
public Serializer() {}
|
||||
|
||||
- public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
||||
+ // Scissors start
|
||||
+ private MutableComponent deserialize(JsonElement jsonelement, JsonDeserializationContext jsondeserializationcontext, int depth) throws JsonParseException {
|
||||
+ if (depth > ScissorsConfig.componentDepthLimit) {
|
||||
+ throw new JsonParseException("Depth limit exceeded");
|
||||
+ }
|
||||
+ // Scissors end
|
||||
if (jsonelement.isJsonPrimitive()) {
|
||||
return Component.literal(jsonelement.getAsString());
|
||||
} else {
|
||||
@@ -273,7 +281,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
JsonElement jsonelement1 = (JsonElement) iterator.next();
|
||||
- MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
|
||||
+ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1); // Scissors
|
||||
|
||||
if (ichatmutablecomponent == null) {
|
||||
ichatmutablecomponent = ichatmutablecomponent1;
|
||||
@@ -297,12 +305,17 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
s = GsonHelper.getAsString(jsonobject, "translate");
|
||||
String s1 = GsonHelper.getAsString(jsonobject, "fallback", (String) null);
|
||||
|
||||
+ // Scissors start - Penalize depth for placeholders in translate & fallback
|
||||
+ long translate_placeholders = PLACEHOLDER_PATTERN.matcher(s).results().count();
|
||||
+ long fallback_placeholders = s1 != null ? PLACEHOLDER_PATTERN.matcher(s1).results().count() : 0;
|
||||
+ int penalty = (int)Math.max(translate_placeholders, fallback_placeholders) * 12;
|
||||
+ // Scissors end
|
||||
if (jsonobject.has("with")) {
|
||||
JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "with");
|
||||
Object[] aobject = new Object[jsonarray1.size()];
|
||||
|
||||
for (int i = 0; i < aobject.length; ++i) {
|
||||
- aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), type, jsondeserializationcontext));
|
||||
+ aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty)); // Scissors
|
||||
}
|
||||
|
||||
ichatmutablecomponent = Component.translatableWithFallback(s, s1, aobject);
|
||||
@@ -318,7 +331,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
|
||||
ichatmutablecomponent = Component.score(GsonHelper.getAsString(jsonobject1, "name"), GsonHelper.getAsString(jsonobject1, "objective"));
|
||||
} else if (jsonobject.has("selector")) {
|
||||
- Optional<Component> optional = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
|
||||
+ Optional<Component> optional = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors
|
||||
|
||||
ichatmutablecomponent = Component.selector(GsonHelper.getAsString(jsonobject, "selector"), optional);
|
||||
} else if (jsonobject.has("keybind")) {
|
||||
@@ -329,7 +342,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
}
|
||||
|
||||
s = GsonHelper.getAsString(jsonobject, "nbt");
|
||||
- Optional<Component> optional1 = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
|
||||
+ Optional<Component> optional1 = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors
|
||||
boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false);
|
||||
Object object;
|
||||
|
||||
@@ -356,7 +369,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
}
|
||||
|
||||
for (int j = 0; j < jsonarray2.size(); ++j) {
|
||||
- ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), type, jsondeserializationcontext));
|
||||
+ ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1)); // Scissors
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +379,12 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
||||
+ return this.deserialize(jsonelement, jsondeserializationcontext, 1);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
private static Object unwrapTextArgument(Object text) {
|
||||
if (text instanceof Component) {
|
||||
Component ichatbasecomponent = (Component) text;
|
||||
@@ -384,8 +403,10 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return text;
|
||||
}
|
||||
|
||||
- private Optional<Component> parseSeparator(Type type, JsonDeserializationContext context, JsonObject json) {
|
||||
- return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), type, context)) : Optional.empty();
|
||||
+ // Scissors start
|
||||
+ private Optional<Component> parseSeparator(JsonDeserializationContext context, JsonObject json, int depth) {
|
||||
+ return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), context, depth + 1)) : Optional.empty();
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
private void serializeStyle(Style style, JsonObject json, JsonSerializationContext context) {
|
86
patches/server/0044-Implement-command-block-events.patch
Normal file
86
patches/server/0044-Implement-command-block-events.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 2 Jun 2023 20:55:18 +0100
|
||||
Subject: [PATCH] Implement command block events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||
index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400deb533d2 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.level.BaseCommandBlock;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class ServerboundSetCommandMinecartPacket implements Packet<ServerGamePacketListener> {
|
||||
- private final int entity;
|
||||
+ public final int entity; // Scissors - private -> public
|
||||
private final String command;
|
||||
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 08390409bbaf9f3ae8260ab36ea5e0580e93b3e3..e2f7cef0edf2775083eb87b1cb5984ec8b25c76f 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 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent; // Scissors
|
||||
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent; // Scissors
|
||||
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
@@ -159,6 +161,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;
|
||||
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock; // Scissors
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -187,6 +190,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;
|
||||
+import org.bukkit.craftbukkit.block.CraftCommandBlock; // Scissors
|
||||
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand; // Scissors
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -1007,6 +1012,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level().getWorld(), tileentitycommand));
|
||||
+
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ s = event.getNewCommand();
|
||||
+ // Scissors end
|
||||
+
|
||||
commandblocklistenerabstract.setCommand(s);
|
||||
commandblocklistenerabstract.setTrackOutput(flag);
|
||||
if (!flag) {
|
||||
@@ -1038,7 +1053,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
|
||||
|
||||
if (commandblocklistenerabstract != null) {
|
||||
- commandblocklistenerabstract.setCommand(packet.getCommand());
|
||||
+ // Scissors start - Implement command block events
|
||||
+ String command = packet.getCommand();
|
||||
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), command, new CraftMinecartCommand(this.cserver, (MinecartCommandBlock) this.player.level().getEntity(packet.entity)));
|
||||
+
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ command = event.getNewCommand();
|
||||
+ commandblocklistenerabstract.setCommand(command);
|
||||
+
|
||||
+ // Scissors end
|
||||
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
|
||||
if (!packet.isTrackOutput()) {
|
||||
commandblocklistenerabstract.setLastOutput((Component) null);
|
110
patches/server/0045-Add-depth-limit-to-SNBT.patch
Normal file
110
patches/server/0045-Add-depth-limit-to-SNBT.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 2 Jun 2023 22:13:54 +0100
|
||||
Subject: [PATCH] Add depth limit to SNBT
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..b70bafe2766efcbcce00287e6511a588560564a6 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
@@ -169,9 +169,56 @@ public class TagParser {
|
||||
}
|
||||
|
||||
this.expect('}');
|
||||
- return compoundTag;
|
||||
+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag; // Scissors - Add depth limit to SNBT
|
||||
}
|
||||
|
||||
+ // Scissors start - Add depth limit to SNBT
|
||||
+ private boolean exceedsDepthLimit(Tag tag) {
|
||||
+ return this.exceedsDepthLimit(0, tag);
|
||||
+ }
|
||||
+
|
||||
+ private boolean exceedsDepthLimit(long depth, Tag tag)
|
||||
+ {
|
||||
+ if (depth > 256)
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (tag instanceof ListTag listTag)
|
||||
+ {
|
||||
+ for (Tag childTag : listTag)
|
||||
+ {
|
||||
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
||||
+
|
||||
+ if (returnValue)
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (tag instanceof CompoundTag compoundTag)
|
||||
+ {
|
||||
+ for (String key: compoundTag.getAllKeys())
|
||||
+ {
|
||||
+ Tag childTag = compoundTag.get(key);
|
||||
+
|
||||
+ if (childTag == null)
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
||||
+
|
||||
+ if (returnValue)
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
private Tag readListTag() throws CommandSyntaxException {
|
||||
this.expect('[');
|
||||
this.reader.skipWhitespace();
|
||||
@@ -203,7 +250,7 @@ public class TagParser {
|
||||
}
|
||||
|
||||
this.expect(']');
|
||||
- return listTag;
|
||||
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; // Scissors - Add depth limit to SNBT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +275,7 @@ public class TagParser {
|
||||
}
|
||||
|
||||
private <T extends Number> List<T> readArray(TagType<?> arrayTypeReader, TagType<?> typeReader) throws CommandSyntaxException {
|
||||
- List<T> list = Lists.newArrayList();
|
||||
+ List<Number> list = Lists.newArrayList(); // Scissors - List<T> -> List<Number>
|
||||
|
||||
while(true) {
|
||||
if (this.reader.peek() != ']') {
|
||||
@@ -241,11 +288,11 @@ public class TagParser {
|
||||
}
|
||||
|
||||
if (typeReader == ByteTag.TYPE) {
|
||||
- list.add((T)((NumericTag)tag).getAsByte());
|
||||
+ list.add(((NumericTag)tag).getAsByte()); // Scissors - Remove (T) cast
|
||||
} else if (typeReader == LongTag.TYPE) {
|
||||
- list.add((T)((NumericTag)tag).getAsLong());
|
||||
+ list.add(((NumericTag)tag).getAsLong()); // Scissors - Remove (T) cast
|
||||
} else {
|
||||
- list.add((T)((NumericTag)tag).getAsInt());
|
||||
+ list.add(((NumericTag)tag).getAsInt()); // Scissors - Remove (T) cast
|
||||
}
|
||||
|
||||
if (this.hasElementSeparator()) {
|
||||
@@ -257,7 +304,7 @@ public class TagParser {
|
||||
}
|
||||
|
||||
this.expect(']');
|
||||
- return list;
|
||||
+ return (List<T>) list; // Scissors - Cast to List<T>
|
||||
}
|
||||
}
|
||||
|
27
patches/server/0046-Limit-beacon-effectRange.patch
Normal file
27
patches/server/0046-Limit-beacon-effectRange.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Wed, 7 Jun 2023 16:50:35 -0300
|
||||
Subject: [PATCH] Limit beacon effectRange
|
||||
|
||||
|
||||
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 5c951ef93fe4cf4f085df86b0cefc02bc2610ab9..1d08e3a9493154e075a289d2eb9a8772289534af 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
|
||||
@@ -83,7 +83,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
private double effectRange = -1;
|
||||
|
||||
public double getEffectRange() {
|
||||
- if (this.effectRange < 0) {
|
||||
+ if (this.effectRange < 0 || this.effectRange > 256) { // Scissors
|
||||
return this.levels * 10 + 10;
|
||||
} else {
|
||||
return effectRange;
|
||||
@@ -428,6 +428,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
||||
+ if (this.effectRange > 256) this.effectRange = 256; // Scissors
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Tue, 13 Jun 2023 18:29:18 -0300
|
||||
Subject: [PATCH] Improve validation of ResourceLocations
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||
index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||
@@ -21,6 +21,7 @@ public final class CraftNamespacedKey {
|
||||
}
|
||||
|
||||
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
|
||||
+ if (minecraft == null) throw new IllegalArgumentException("Null ResourceLocation provided"); // Scissors
|
||||
return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath());
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Sat, 1 Jul 2023 21:22:29 -0300
|
||||
Subject: [PATCH] Don't log on too many chained updates
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
index ec81be70cd6f92bbf9011395cb361f0ce54c5ad0..97da1db83dca24759b52fc2d0a360187dbef86f1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||
@@ -56,7 +56,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
||||
this.stack.push(entry);
|
||||
}
|
||||
} else if (this.count - 1 == this.maxChainedNeighborUpdates) {
|
||||
- LOGGER.error("Too many chained neighbor updates. Skipping the rest. First skipped position: " + pos.toShortString());
|
||||
+ // Scissors - don't log
|
||||
}
|
||||
|
||||
if (!bl) {
|
46
patches/server/0049-Fix-packet-related-lag-exploits.patch
Normal file
46
patches/server/0049-Fix-packet-related-lag-exploits.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Tue, 4 Jul 2023 18:49:34 -0300
|
||||
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 e2f7cef0edf2775083eb87b1cb5984ec8b25c76f..c645e05ec6c309448460c7e983931b9dc79a7f7e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -972,7 +972,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
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"));
|
||||
- } else {
|
||||
+ } else if (this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BaseCommandBlock commandblocklistenerabstract = null;
|
||||
CommandBlockEntity tileentitycommand = null;
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1139,7 +1139,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level().getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
@@ -1197,7 +1197,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level().getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
@@ -1220,7 +1220,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
|
44
patches/server/0050-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
44
patches/server/0050-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 5 Jul 2023 22:58:24 +0100
|
||||
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
|
||||
--- 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 {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
this.hivePos = null;
|
||||
- if (nbt.contains("HivePos")) {
|
||||
- this.hivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||
+ if (nbt.contains("HivePos"))
|
||||
+ {
|
||||
+ // Scissors start - Limit HivePos
|
||||
+ final BlockPos savedHivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||
+ this.hivePos = this.level().isLoadedAndInBounds(savedHivePos) ? savedHivePos : null;
|
||||
+ // Scissors end - Limit HivePos
|
||||
}
|
||||
|
||||
this.savedFlowerPos = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
index 65cb385ab294e362d666a6d03c4496cdc3b64890..42c3e946e51f6dcb100078969a4fb46c77f42b2d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
@@ -118,8 +118,12 @@ public class Vex extends Monster implements TraceableEntity {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
- if (nbt.contains("BoundX")) {
|
||||
- this.boundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||
+ if (nbt.contains("BoundX"))
|
||||
+ {
|
||||
+ // Scissors start - Limit Vex bound origin
|
||||
+ final BlockPos savedBoundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||
+ this.boundOrigin = this.level().isLoadedAndInBounds(savedBoundOrigin) ? savedBoundOrigin : null;
|
||||
+ // Scissors end - Limit Vex bound origin
|
||||
}
|
||||
|
||||
if (nbt.contains("LifeTicks")) {
|
32
patches/server/0051-Mute-invalid-attributes.patch
Normal file
32
patches/server/0051-Mute-invalid-attributes.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Thu, 6 Jul 2023 23:01:12 +0100
|
||||
Subject: [PATCH] Mute invalid attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index dd1102d5291ef6f18e82400a6d8a0a376cc071e9..d304612325d6c70a4100582d6c0fbfeecd8716d1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -145,7 +145,7 @@ public class AttributeMap {
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
- LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string);
|
||||
+ // LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string); // Scissors - Mute invalid attributes
|
||||
});
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
index 8de09eea46c27db9d8c472e84f768976769d1b0b..c8d05d35368e0cf593bcc3589b6c108a901bdc22 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
@@ -90,7 +90,7 @@ public class AttributeModifier {
|
||||
AttributeModifier.Operation operation = AttributeModifier.Operation.fromValue(nbt.getInt("Operation"));
|
||||
return new AttributeModifier(uUID, nbt.getString("Name"), nbt.getDouble("Amount"), operation);
|
||||
} catch (Exception var3) {
|
||||
- LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage());
|
||||
+ // LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage()); // Scissors - Mute invalid attributes
|
||||
return null;
|
||||
}
|
||||
}
|
32
patches/server/0052-Mute-invalid-Enderdragon-phases.patch
Normal file
32
patches/server/0052-Mute-invalid-Enderdragon-phases.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Thu, 6 Jul 2023 23:34:46 +0100
|
||||
Subject: [PATCH] Mute invalid Enderdragon phases
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
index bca131e9c428e2cb073ae2ef517dda12f73a5dcd..b9d603c82b12299e94c31928b36c9517834cff62 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
@@ -20,7 +20,7 @@ public class DragonChargePlayerPhase extends AbstractDragonPhaseInstance {
|
||||
@Override
|
||||
public void doServerTick() {
|
||||
if (this.targetLocation == null) {
|
||||
- LOGGER.warn("Aborting charge player as no target was set.");
|
||||
+ // LOGGER.warn("Aborting charge player as no target was set."); // Scissors - Mute invalid Enderdragon phases
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
} else if (this.timeSinceCharge > 0 && this.timeSinceCharge++ >= 10) {
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
index a3456b35db4e938f91d6bc32d4d202a011bf13c4..aad0b066e4fd63195aa117c5a03f64846bf46fbd 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
@@ -32,7 +32,7 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance {
|
||||
@Override
|
||||
public void doServerTick() {
|
||||
if (this.attackTarget == null) {
|
||||
- LOGGER.warn("Skipping player strafe phase because no player was found");
|
||||
+ // LOGGER.warn("Skipping player strafe phase because no player was found"); // Scissors - Mute invalid Enderdragon phases
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
} else {
|
||||
if (this.currentPath != null && this.currentPath.isDone()) {
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 25 Aug 2023 11:51:47 +0100
|
||||
Subject: [PATCH] Add length limit to note block sound
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||
index a2fc2c0437999dd09f080eafe8ea466b16cdf57b..0dcf1d7e041477fe31dce4b4ee707399520d30f2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||
@@ -80,7 +80,7 @@ public class SkullBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
if (nbt.contains("note_block_sound", 8)) {
|
||||
- this.noteBlockSound = ResourceLocation.tryParse(nbt.getString("note_block_sound"));
|
||||
+ this.noteBlockSound = ResourceLocation.tryParse(StringUtil.truncateStringIfNecessary(nbt.getString("note_block_sound"), 32767, false)); // Scissors - Add length limit to note block sound
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user