add rest of patches
This commit is contained in:
parent
6bd65484c7
commit
691b45b7ef
|
@ -0,0 +1,85 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Mon, 15 Apr 2024 23:27:16 -0500
|
||||
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 88c98ba7673808819b8f85876f22743bc3a4f471..f96c0c5007d9e1d86bfe27518815dc798e431c6a 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;
|
||||
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
|
||||
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
|
||||
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;
|
||||
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;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.inventory.BeaconMenu;
|
||||
@@ -189,6 +192,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;
|
||||
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -905,6 +910,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
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) {
|
||||
@@ -936,7 +951,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
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);
|
|
@ -0,0 +1,101 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Mon, 15 Apr 2024 23:40:27 -0500
|
||||
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 c77860a141064aea6a0b510bb44d35fea90aee42..3be3dd61b8a27b3a8ca3c72ae5ffa2ea8fa00231 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
@@ -184,9 +184,47 @@ public class TagParser {
|
||||
|
||||
this.expect('}');
|
||||
this.depth--; // Paper
|
||||
- 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();
|
||||
@@ -220,7 +258,7 @@ public class TagParser {
|
||||
|
||||
this.expect(']');
|
||||
this.depth--; // Paper
|
||||
- return listTag;
|
||||
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; // Scissors - Add depth limit to SNBT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,7 +283,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 (this.reader.peek() != ']') {
|
||||
int i = this.reader.getCursor();
|
||||
@@ -257,11 +295,11 @@ public class TagParser {
|
||||
}
|
||||
|
||||
if (typeReader == ByteTag.TYPE) {
|
||||
- list.add((T)(Byte)((NumericTag)tag).getAsByte()); // Paper - decompile fix
|
||||
+ list.add(((NumericTag)tag).getAsByte()); // Scissors - Remove (T) cast
|
||||
} else if (typeReader == LongTag.TYPE) {
|
||||
- list.add((T)(Long)((NumericTag)tag).getAsLong()); // Paper - decompile fix
|
||||
+ list.add(((NumericTag)tag).getAsLong()); // Scissors - Remove (T) cast
|
||||
} else {
|
||||
- list.add((T)(Integer)((NumericTag)tag).getAsInt()); // Paper - decompile fix
|
||||
+ list.add(((NumericTag)tag).getAsInt()); // Scissors - Remove (T) cast
|
||||
}
|
||||
|
||||
if (!this.hasElementSeparator()) {
|
||||
@@ -274,7 +312,7 @@ public class TagParser {
|
||||
}
|
||||
|
||||
this.expect(']');
|
||||
- return list;
|
||||
+ return (List<T>) list; // Scissors - Cast to List<T>
|
||||
}
|
||||
|
||||
private boolean hasElementSeparator() {
|
Loading…
Reference in New Issue