mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-06-28 08:16:41 +00:00
This is all of them except 1
This commit is contained in:
@ -6,10 +6,10 @@ Subject: [PATCH] Validate coordinates before attempting to get block entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4ab50df1e4c855587ef030cf3f2a1502798cb721..c7d7711be1bd17a25c98578ad68154255135facd 100644
|
||||
index 0c2255b6e2fb7752f85b0f83d4f84732758bd14d..ff72911cca59528f7090533e52450a59ea50a92a 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1934,6 +1934,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@@ -1926,6 +1926,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
// Spigot end
|
||||
|
||||
@ -28,7 +28,7 @@ index 4ab50df1e4c855587ef030cf3f2a1502798cb721..c7d7711be1bd17a25c98578ad6815425
|
||||
@Override
|
||||
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
@@ -3451,17 +3463,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@@ -3310,17 +3322,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
||||
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
|
||||
|
||||
|
54
patches/server/0023-Reset-large-tags.patch
Normal file
54
patches/server/0023-Reset-large-tags.patch
Normal file
@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:38:53 -0600
|
||||
Subject: [PATCH] Reset large tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 8450a22b0fc6e8dc5cad0f61ac52a82b3cd3791e..4ed50b7863bdc762775064b777a7d0e733ee52fe 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -20,6 +20,7 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
@@ -255,6 +256,12 @@ public final class ItemStack {
|
||||
|
||||
// CraftBukkit - break into own method
|
||||
private void load(CompoundTag nbttagcompound) {
|
||||
+ // Scissors start - Reset large tags
|
||||
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
||||
+ // Reset tag without destroying item
|
||||
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -515,7 +522,11 @@ public final class ItemStack {
|
||||
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
|
||||
nbt.putByte("Count", (byte) this.count);
|
||||
if (this.tag != null) {
|
||||
- nbt.put("tag", this.tag.copy());
|
||||
+ // Scissors start - Don't save large tags
|
||||
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
||||
+ nbt.put("tag", this.tag.copy());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
return nbt;
|
||||
@@ -846,6 +857,9 @@ public final class ItemStack {
|
||||
// Paper end
|
||||
|
||||
public void setTag(@Nullable CompoundTag nbt) {
|
||||
+ // Scissors start - Ignore large tags
|
||||
+ if (NbtUtility.isTooLarge(nbt)) return;
|
||||
+ // Scissors end
|
||||
this.tag = nbt;
|
||||
this.processEnchantOrder(this.tag); // Paper
|
||||
if (this.getItem().canBeDepleted()) {
|
260
patches/server/0024-Account-for-items-inside-containers.patch
Normal file
260
patches/server/0024-Account-for-items-inside-containers.patch
Normal file
@ -0,0 +1,260 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Sat, 11 Jun 2022 23:33:13 -0500
|
||||
Subject: [PATCH] Account for items inside containers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4bbf604c1 100644
|
||||
--- a/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
+++ b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -22,10 +23,13 @@ public class ContainerHelper {
|
||||
|
||||
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
||||
ListTag listTag = new ListTag();
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
|
||||
for(int i = 0; i < stacks.size(); ++i) {
|
||||
ItemStack itemStack = stacks.get(i);
|
||||
if (!itemStack.isEmpty()) {
|
||||
+ total += NbtUtility.getTagSize(itemStack.getTag()); // Scissors
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
compoundTag.putByte("Slot", (byte)i);
|
||||
itemStack.save(compoundTag);
|
||||
@@ -33,7 +37,7 @@ public class ContainerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
- if (!listTag.isEmpty() || setIfEmpty) {
|
||||
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) { // Scissors
|
||||
nbt.put("Items", listTag);
|
||||
}
|
||||
|
||||
@@ -42,11 +46,18 @@ public class ContainerHelper {
|
||||
|
||||
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
|
||||
ListTag listTag = nbt.getList("Items", 10);
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
|
||||
for(int i = 0; i < listTag.size(); ++i) {
|
||||
CompoundTag compoundTag = listTag.getCompound(i);
|
||||
int j = compoundTag.getByte("Slot") & 255;
|
||||
if (j >= 0 && j < stacks.size()) {
|
||||
+ total += NbtUtility.getTagSize(compoundTag);
|
||||
+ if (total >= NbtUtility.MAXIMUM_SIZE) {
|
||||
+ stacks.clear();
|
||||
+ break;
|
||||
+ }
|
||||
stacks.set(j, ItemStack.of(compoundTag));
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index cac2768fe520b591990c7bc943ae7e95f49efb31..f734cba350ed85dbbf52ff527c9bb14b9eb04c86 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -211,6 +212,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d75be8ed8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -34,6 +35,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
index 55006724ccec9f3de828ec18693728e9741ff65f..e6e59b2cfa1ced3756bf350905c0350ac7fd34f9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -71,6 +72,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||
}
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731029b32ab 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -40,6 +41,16 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd76522e1b191 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -28,6 +29,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index ccad692aba2ed77259f6814d88f01b91ed9d229b..da4fc1027e106fd4e4baedd7b9490c41b0e38bd5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -52,6 +53,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.items) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
return this.items;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d3194b66070 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -60,6 +61,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
public boolean opened;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
+ for (ItemStack item : this.itemStacks) {
|
||||
+ total += NbtUtility.getTagSize(item.getOrCreateTag());
|
||||
+ }
|
||||
+
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.itemStacks.clear();
|
||||
+ }
|
||||
return this.itemStacks;
|
||||
}
|
||||
|
@ -0,0 +1,109 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:44:05 -0600
|
||||
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
||||
vehicles if they collide with more than 15 other entities
|
||||
|
||||
|
||||
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 eec7d7a5b558830111831792c42665724613af23..79f296388a7f86944f33b9a783ab81b3a9e4d4dc 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;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.Util;
|
||||
@@ -105,6 +106,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
|
||||
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
||||
public double maxSpeed = 0.4D;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -431,8 +433,10 @@ 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 - Add a collision debounce
|
||||
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
||||
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
||||
+ for (int l = 0; l < Math.min(3, list.size()); ++l) {
|
||||
Entity entity = (Entity) list.get(l);
|
||||
|
||||
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
|
||||
@@ -459,6 +463,16 @@ public abstract class AbstractMinecart extends Entity {
|
||||
entity.push(this);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Scissors - Add a collision debounce
|
||||
+ if (list.size() > 3) {
|
||||
+ lastLargeCollision = System.currentTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ // Scissors - Delete entity if the collision amount is over 15
|
||||
+ if (list.size() > 15) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
Iterator iterator = 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 85e1892866cd2ee0cec1552b8541c1f800bdf68c..2950f60e068cbeb945cfe38972eaf65b79e3a4f1 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;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.IntFunction;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -108,6 +109,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
public double unoccupiedDeceleration = -1;
|
||||
public boolean landBoats = false;
|
||||
// CraftBukkit end
|
||||
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
||||
|
||||
public Boat(EntityType<? extends Boat> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -417,10 +419,12 @@ 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()) {
|
||||
+ // Scissors - Add collision debounce
|
||||
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
||||
boolean flag = !this.level.isClientSide && !(this.getControllingPassenger() instanceof Player);
|
||||
|
||||
- for (int j = 0; j < list.size(); ++j) {
|
||||
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
||||
+ for (int j = 0; j < Math.min(3, list.size()); ++j) {
|
||||
Entity entity = (Entity) list.get(j);
|
||||
|
||||
if (!entity.hasPassenger((Entity) this)) {
|
||||
@@ -431,6 +435,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Scissors - Add collision debounce
|
||||
+ if (list.size() > 3) {
|
||||
+ lastLargeCollision = System.currentTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ // Scissors - Delete entity if the collision amount is over 15
|
||||
+ if (list.size() > 15) {
|
||||
+ this.discard();
|
||||
+ }
|
||||
}
|
||||
|
||||
}
|
21
patches/server/0026-Don-t-log-invalid-teams-to-console.patch
Normal file
21
patches/server/0026-Don-t-log-invalid-teams-to-console.patch
Normal file
@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 17 May 2022 05:57:52 +0100
|
||||
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 2012c147f60f39ae7dbae74641fd00b3b282a991..d828b838216083192d9a344ca978f6a7360e0363 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -850,7 +850,9 @@ public abstract class LivingEntity extends Entity {
|
||||
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||
|
||||
if (!flag) {
|
||||
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
||||
+ // Scissors start - Prevent log spam possible with this error message, easily provokable by players in creative.
|
||||
+ // LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,194 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:48:28 -0600
|
||||
Subject: [PATCH] Better handling of invalid JSON components
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index 3ca733528acb40354b308019a84436ea67e05751..76932c683153c7dcbf46de78cccc14772babc5fc 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 net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
||||
import net.minecraft.network.chat.contents.DataSource;
|
||||
@@ -506,6 +507,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return GsonHelper.toStableString(Serializer.toJsonTree(text));
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ @Nullable
|
||||
+ public static MutableComponent fromJsonSafe(String json) {
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public static MutableComponent fromJsonSafe(JsonElement json) {
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
public static JsonElement toJsonTree(Component text) {
|
||||
return Component.Serializer.GSON.toJsonTree(text);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b2164001283cab7 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||
@@ -79,7 +79,7 @@ public class HoverEvent {
|
||||
if (jsonElement != null) {
|
||||
return action.deserialize(jsonElement);
|
||||
} else {
|
||||
- Component component = Component.Serializer.fromJson(json.get("value"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(json.get("value")); // Scissors - Use safer method for getting Components from JSON
|
||||
return component != null ? action.deserializeFromLegacy(component) : null;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class HoverEvent {
|
||||
}
|
||||
|
||||
public static class Action<T> {
|
||||
- public static final HoverEvent.Action<Component> SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJson, Component.Serializer::toJsonTree, Function.identity());
|
||||
+ public static final HoverEvent.Action<Component> SHOW_TEXT = new HoverEvent.Action<>("show_text", true, Component.Serializer::fromJsonSafe, Component.Serializer::toJsonTree, Function.identity()); // Scissors - Use safer method for getting Components from JSON
|
||||
public static final HoverEvent.Action<HoverEvent.ItemStackInfo> SHOW_ITEM = new HoverEvent.Action<>("show_item", true, HoverEvent.ItemStackInfo::create, HoverEvent.ItemStackInfo::serialize, HoverEvent.ItemStackInfo::create);
|
||||
public static final HoverEvent.Action<HoverEvent.EntityTooltipInfo> SHOW_ENTITY = new HoverEvent.Action<>("show_entity", true, HoverEvent.EntityTooltipInfo::create, HoverEvent.EntityTooltipInfo::serialize, HoverEvent.EntityTooltipInfo::create);
|
||||
private static final Map<String, HoverEvent.Action<?>> LOOKUP = Stream.of(SHOW_TEXT, SHOW_ITEM, SHOW_ENTITY).collect(ImmutableMap.toImmutableMap(HoverEvent.Action::getName, (action) -> {
|
||||
@@ -182,7 +182,7 @@ public class HoverEvent {
|
||||
return null;
|
||||
}
|
||||
// Scissors end
|
||||
- Component component = Component.Serializer.fromJson(jsonObject.get("name"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(jsonObject.get("name")); // Scissors - Use safer method for getting Components from JSON
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class HoverEvent {
|
||||
public static HoverEvent.EntityTooltipInfo create(Component text) {
|
||||
try {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("name")); // Scissors - Use safer method for getting Components from JSON
|
||||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||
// Scissors start
|
||||
UUID uUID;
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||
index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e1146dbdc3f 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||
@@ -8,6 +8,7 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.NbtPathArgument;
|
||||
import net.minecraft.nbt.Tag;
|
||||
@@ -107,10 +108,11 @@ public class NbtContents implements ComponentContents {
|
||||
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
|
||||
return stream.flatMap((text) -> {
|
||||
try {
|
||||
- MutableComponent mutableComponent = Component.Serializer.fromJson(text);
|
||||
+ MutableComponent mutableComponent = Component.Serializer.fromJsonSafe(text); // Scissors
|
||||
return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth));
|
||||
} catch (Exception var5) {
|
||||
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||
+ // Scissors - don't log
|
||||
+ // LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||
return Stream.of();
|
||||
}
|
||||
}).reduce((accumulator, current) -> {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 7f94da8059147760cbdc2476d0e8beda4a105f40..1f7462cb8d71e703412fc802c54cdf0b85f8054b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2330,12 +2330,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
String s = nbt.getString("CustomName");
|
||||
-
|
||||
- try {
|
||||
- this.setCustomName(Component.Serializer.fromJson(s));
|
||||
- } catch (Exception exception) {
|
||||
- Entity.LOGGER.warn("Failed to parse entity custom name {}", s, exception);
|
||||
- }
|
||||
+ this.setCustomName(Component.Serializer.fromJsonSafe(s)); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
||||
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 49ca1d45bb4b3ddafc1d5952ff9830ba69b745e2..54ef6d8b7144c1872bf137fc9b387641ef99afa9 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
|
||||
@@ -410,7 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
||||
// CraftBukkit end
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
index 65e1381bb2d10bd212463feb602c60f8fdb9ade1..3e23451066894ebd88cad7022970cb2c0e9b75db 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||
@@ -42,7 +42,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1a2417616 100644
|
||||
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
@@ -35,7 +35,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
CompoundTag compoundTag = nbt.getCompound(i);
|
||||
String string = compoundTag.getString("Name");
|
||||
PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string);
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component != null) {
|
||||
playerTeam.setDisplayName(component);
|
||||
}
|
||||
@@ -53,14 +53,14 @@ public class ScoreboardSaveData extends SavedData {
|
||||
}
|
||||
|
||||
if (compoundTag.contains("MemberNamePrefix", 8)) {
|
||||
- Component component2 = Component.Serializer.fromJson(compoundTag.getString("MemberNamePrefix"));
|
||||
+ Component component2 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNamePrefix")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component2 != null) {
|
||||
playerTeam.setPlayerPrefix(component2);
|
||||
}
|
||||
}
|
||||
|
||||
if (compoundTag.contains("MemberNameSuffix", 8)) {
|
||||
- Component component3 = Component.Serializer.fromJson(compoundTag.getString("MemberNameSuffix"));
|
||||
+ Component component3 = Component.Serializer.fromJsonSafe(compoundTag.getString("MemberNameSuffix")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component3 != null) {
|
||||
playerTeam.setPlayerSuffix(component3);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
CompoundTag compoundTag = nbt.getCompound(i);
|
||||
ObjectiveCriteria.byName(compoundTag.getString("CriteriaName")).ifPresent((criterion) -> {
|
||||
String string = compoundTag.getString("Name");
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType"));
|
||||
this.scoreboard.addObjective(string, criterion, component, renderType);
|
||||
});
|
@ -0,0 +1,35 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Fri, 25 Nov 2022 22:25:24 -0600
|
||||
Subject: [PATCH] Reject oversized components from updating
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
index 9d0d5a44c5948bde037165147d18aaabe21ce50a..c42b8b4daa1ffa6f3ae89b35056edbf61ae47283 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
@@ -39,8 +39,10 @@ public class ComponentUtils {
|
||||
}
|
||||
|
||||
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||
+ // Scissors start - Reject oversized components
|
||||
+ MutableComponent result;
|
||||
if (depth > 100) {
|
||||
- return text.copy();
|
||||
+ result = text.copy();
|
||||
} else {
|
||||
// Paper start
|
||||
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
||||
@@ -53,8 +55,11 @@ public class ComponentUtils {
|
||||
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
||||
}
|
||||
|
||||
- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||
}
|
||||
+ // Would the resulting component exceed 65535 bytes when encoded as a string?
|
||||
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result;
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
193
patches/server/0029-Block-server-side-chunkbans.patch
Normal file
193
patches/server/0029-Block-server-side-chunkbans.patch
Normal file
@ -0,0 +1,193 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ayunami2000 <spwilliamsiam@gmail.com>
|
||||
Date: Fri, 17 Jun 2022 15:28:43 -0500
|
||||
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 5fce1177e7198d791d4ab1c64b394c5b1c145782..744d93fac1db1a8cd6d6ce37de717db97ccf73a1 100644
|
||||
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
@@ -6,9 +6,18 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
import java.io.IOException;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
|
||||
+import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||
import net.minecraft.util.profiling.jfr.JvmProfiler;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
@@ -41,30 +50,101 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
packet.write(friendlyByteBuf);
|
||||
int j = friendlyByteBuf.writerIndex() - i;
|
||||
if (j > 8388608) {
|
||||
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
|
||||
+ // Scissors start
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
+ // Scissors end
|
||||
} else {
|
||||
int k = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
|
||||
JvmProfiler.INSTANCE.onPacketSent(k, integer, channelHandlerContext.channel().remoteAddress(), j);
|
||||
}
|
||||
} catch (Throwable var10) {
|
||||
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var10); // Paper - Give proper error message
|
||||
- if (packet.isSkippable()) {
|
||||
- throw new SkipPacketException(var10);
|
||||
- } else {
|
||||
- throw var10;
|
||||
- }
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
}
|
||||
|
||||
// Paper start
|
||||
int packetLength = friendlyByteBuf.readableBytes();
|
||||
if (packetLength > MAX_PACKET_SIZE) {
|
||||
- throw new PacketTooLargeException(packet, packetLength);
|
||||
+ // Scissors start
|
||||
+ friendlyByteBuf.clear();
|
||||
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
|
||||
+ packetLength = friendlyByteBuf.readableBytes();
|
||||
+ if (packetLength > MAX_PACKET_SIZE) {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
+ private static void noKicking(FriendlyByteBuf friendlyByteBuf, Packet packet, Integer integer, ChannelHandlerContext channelHandlerContext)
|
||||
+ {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ friendlyByteBuf.writeVarInt(integer);
|
||||
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
||||
+ boolean didIt = true;
|
||||
+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket)
|
||||
+ {
|
||||
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundLevelChunkPacketData chunkPacket)
|
||||
+ {
|
||||
+ chunkPacket.clearNBT();
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundSetEntityDataPacket entityDataPacket)
|
||||
+ {
|
||||
+ friendlyByteBuf.writeVarInt(entityDataPacket.getId());
|
||||
+ friendlyByteBuf.writeByte(255);
|
||||
+ didIt = false;//prevent default packet writing
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket)
|
||||
+ {
|
||||
+ containerSetContentPacket.clearNBT();
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket)
|
||||
+ {
|
||||
+ friendlyByteBuf.writeVarInt(setEquipmentPacket.getEntity());
|
||||
+ didIt = false; //prevent default
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket)
|
||||
+ {
|
||||
+ friendlyByteBuf.writeByte(containerSetSlotPacket.getContainerId());
|
||||
+ friendlyByteBuf.writeVarInt(containerSetSlotPacket.getStateId());
|
||||
+ friendlyByteBuf.writeShort(containerSetSlotPacket.getSlot());
|
||||
+ friendlyByteBuf.writeItem(ItemStack.EMPTY);
|
||||
+ didIt = false; //prevent default
|
||||
+ }
|
||||
+ else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket)
|
||||
+ {
|
||||
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ didIt = false;
|
||||
+ LOGGER.info(packet.getClass().getName() + " overflowed/errored and was not caught!!");
|
||||
+ }
|
||||
+ if (didIt)
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ int i = friendlyByteBuf.writerIndex();
|
||||
+ packet.write(friendlyByteBuf);
|
||||
+ int j = friendlyByteBuf.writerIndex() - i;
|
||||
+ if (j > 8388608)
|
||||
+ {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ }
|
||||
+ }
|
||||
+ catch (Throwable var69)
|
||||
+ {
|
||||
+ friendlyByteBuf.clear();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Paper start
|
||||
private static int MAX_PACKET_SIZE = 2097152;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||
index 3944852921335c78a04a9dc301882ab5b152b1ed..0d88828bc0bbd68328da4d0e7d3b880006d2c775 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
||||
@@ -24,7 +24,8 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
|
||||
return create(blockEntity, BlockEntity::getUpdateTag);
|
||||
}
|
||||
|
||||
- private ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) {
|
||||
+ // Scissors - make this public
|
||||
+ public ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) {
|
||||
this.pos = pos;
|
||||
this.type = blockEntityType;
|
||||
this.tag = nbt.isEmpty() ? null : nbt;
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
index dbd8b9b09b82c1b75e8be9dc7416d9f0863c8c87..24e0f4ee1dc9b5a46ed063e087d4b7bcd2a7fe46 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
|
||||
@@ -10,7 +10,15 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
|
||||
private final int containerId;
|
||||
private final int stateId;
|
||||
private final List<ItemStack> items;
|
||||
- private final ItemStack carriedItem;
|
||||
+ private ItemStack carriedItem; // Scissors - removed "final"
|
||||
+
|
||||
+ // Scissors start
|
||||
+ public void clearNBT()
|
||||
+ {
|
||||
+ this.items.clear();
|
||||
+ this.carriedItem = ItemStack.EMPTY;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
|
||||
public ClientboundContainerSetContentPacket(int syncId, int revision, NonNullList<ItemStack> contents, ItemStack cursorStack) {
|
||||
this.containerId = syncId;
|
||||
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 f3fa2678796c33f3a408a02a1995ad117eac9169..c8dd976240aa4f640bb2d223d472f81fdd8dcf7c 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,14 @@ public class ClientboundLevelChunkPacketData {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Scissors start
|
||||
+ public void clearNBT()
|
||||
+ {
|
||||
+ this.blockEntitiesData.clear();
|
||||
+ this.extraPackets.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Paper start - Anti-Xray - Add chunk packet info
|
||||
@Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); }
|
||||
public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
|
176
patches/server/0030-Add-MasterBlockFireEvent.patch
Normal file
176
patches/server/0030-Add-MasterBlockFireEvent.patch
Normal file
@ -0,0 +1,176 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 4 Jul 2022 22:12:19 +0100
|
||||
Subject: [PATCH] Add MasterBlockFireEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f69414d6e295 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -25,10 +26,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
+import org.bukkit.Location;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
-
|
||||
public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -117,6 +118,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
}
|
||||
|
||||
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (hasCommand) {
|
||||
executor.performCommand(world);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/StructureBlock.java b/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
||||
index a3dac53b07618819b322b48339d850d80a1c55ba..4dd21b7ea247b3ced3d3ee6c67746cc6811d5bb8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a1c1a2553 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.level.block.entity;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
+
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -17,6 +19,7 @@ import net.minecraft.world.level.block.JigsawBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
+import org.bukkit.Location;
|
||||
|
||||
public class JigsawBlockEntity extends BlockEntity {
|
||||
public static final String TARGET = "target";
|
||||
@@ -107,6 +110,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos pos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front());
|
||||
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
|
||||
// Paper start - Replace getHolderOrThrow with a null check
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cdedecb710e1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
@@ -5,6 +5,8 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
+import org.bukkit.Location;
|
||||
|
||||
public class StructureBlockEntity extends BlockEntity {
|
||||
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
|
||||
@@ -264,7 +267,6 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
- int i = 80;
|
||||
BlockPos blockPos2 = new BlockPos(blockPos.getX() - 80, this.level.getMinBuildHeight(), blockPos.getZ() - 80);
|
||||
BlockPos blockPos3 = new BlockPos(blockPos.getX() + 80, this.level.getMaxBuildHeight() - 1, blockPos.getZ() + 80);
|
||||
Stream<BlockPos> stream = this.getRelatedCorners(blockPos2, blockPos3);
|
||||
@@ -321,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean saveStructure(boolean bl) {
|
||||
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos pos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
||||
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl) {
|
||||
if (this.mode == StructureMode.LOAD && this.structureName != null) {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
StructureTemplateManager structureTemplateManager = world.getStructureManager();
|
||||
|
||||
Optional<StructureTemplate> optional;
|
||||
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void unloadStructure() {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.structureName != null) {
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
32
patches/server/0031-Add-spectator-teleport-event.patch
Normal file
32
patches/server/0031-Add-spectator-teleport-event.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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 ff72911cca59528f7090533e52450a59ea50a92a..8d626169874c4188e2a9bc214b1c0af9689b11b3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
+import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
@@ -2072,6 +2073,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
+ // Scissors start - Add spectator teleport event
|
||||
+ final SpectatorTeleportEvent event = new SpectatorTeleportEvent(this.player.getBukkitEntity(), entity.getBukkitEntity());
|
||||
+
|
||||
+ if(!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
|
||||
return;
|
||||
}
|
46
patches/server/0032-Prevent-invalid-container-events.patch
Normal file
46
patches/server/0032-Prevent-invalid-container-events.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
||||
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 8d626169874c4188e2a9bc214b1c0af9689b11b3..53a71e699e885aa36fcc07f04fb5f15e4661b7f2 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -29,6 +29,8 @@ import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -2952,6 +2954,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (this.player.isImmobile()) return; // CraftBukkit
|
||||
+
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
||||
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
||||
@@ -2973,6 +2976,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
+ .color(NamedTextColor.RED)
|
||||
+ );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
||||
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
||||
|
@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:55:33 +0100
|
||||
Subject: [PATCH] Do not attempt to cast items to recipes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index f734cba350ed85dbbf52ff527c9bb14b9eb04c86..68912cc2bd670944465e6819d82c4aad6b7b324a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -642,6 +642,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
Entry<ResourceLocation> entry = (Entry) objectiterator.next();
|
||||
|
||||
worldserver.getRecipeManager().byKey((ResourceLocation) entry.getKey()).ifPresent((irecipe) -> {
|
||||
+ // Scissors start - Do not attempt to cast items to recipes
|
||||
+ if (!(irecipe instanceof AbstractCookingRecipe))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
list.add(irecipe);
|
||||
AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
|
||||
});
|
@ -0,0 +1,483 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:15:20 +0100
|
||||
Subject: [PATCH] Add Scissors configuration file & command
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
index 06bff37e4c1fddd3be6343049a66787c63fb420c..1c1cb20190e8edb7f55a60fc662c28e204690223 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
@@ -25,6 +25,7 @@ package co.aikar.timings;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
@@ -241,7 +242,8 @@ public class TimingsExport extends Thread {
|
||||
parent.put("config", createObject(
|
||||
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
||||
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
||||
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
|
||||
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
|
||||
+ pair("scissors", mapAsJSON(ScissorsConfig.config, null)) // Scissors
|
||||
));
|
||||
|
||||
new TimingsExport(listeners, parent, history).start();
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67ed3d6e95
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
||||
@@ -0,0 +1,150 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+import com.google.common.base.Functions;
|
||||
+import com.google.common.base.Joiner;
|
||||
+import com.google.common.collect.ImmutableSet;
|
||||
+import com.google.common.collect.Iterables;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.util.*;
|
||||
+import java.util.stream.Collectors;
|
||||
+
|
||||
+public class ScissorsCommand extends Command
|
||||
+{
|
||||
+
|
||||
+ private static final String BASE_PERM = "bukkit.command.scissors.";
|
||||
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("reload", "version").build();
|
||||
+
|
||||
+ public ScissorsCommand(String name)
|
||||
+ {
|
||||
+ super(name);
|
||||
+ this.description = "Scissors related commands";
|
||||
+ this.usageMessage = "/scissors [" + Joiner.on(" | ").join(SUBCOMMANDS) + "]";
|
||||
+ this.setPermission("bukkit.command.scissors;" + Joiner.on(';').join(SUBCOMMANDS.stream().map(s -> BASE_PERM + s).collect(Collectors.toSet())));
|
||||
+ }
|
||||
+
|
||||
+ private static boolean testPermission(CommandSender commandSender, String permission)
|
||||
+ {
|
||||
+ if (commandSender.hasPermission(BASE_PERM + permission) || commandSender.hasPermission("bukkit.command.scissors"))
|
||||
+ return true;
|
||||
+ commandSender.sendMessage(Bukkit.getPermissionMessage()); // Sorry, kashike
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Code from Mojang - copyright them
|
||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] args, String... matches)
|
||||
+ {
|
||||
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
|
||||
+ }
|
||||
+
|
||||
+ public static boolean matches(String s, String s1)
|
||||
+ {
|
||||
+ return s1.regionMatches(true, 0, s, 0, s.length());
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] strings, Collection<?> collection)
|
||||
+ {
|
||||
+ String last = strings[strings.length - 1];
|
||||
+ ArrayList<String> results = Lists.newArrayList();
|
||||
+
|
||||
+ if (!collection.isEmpty())
|
||||
+ {
|
||||
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
|
||||
+
|
||||
+ while (iterator.hasNext())
|
||||
+ {
|
||||
+ String s1 = (String) iterator.next();
|
||||
+
|
||||
+ if (matches(last, s1) && (sender.hasPermission(BASE_PERM + s1) || sender.hasPermission("bukkit.command.scissors")))
|
||||
+ {
|
||||
+ results.add(s1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (results.isEmpty())
|
||||
+ {
|
||||
+ iterator = collection.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext())
|
||||
+ {
|
||||
+ Object object = iterator.next();
|
||||
+
|
||||
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath()))
|
||||
+ {
|
||||
+ results.add(String.valueOf(object));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return results;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException
|
||||
+ {
|
||||
+ if (args.length <= 1)
|
||||
+ return getListMatchingLast(sender, args, SUBCOMMANDS);
|
||||
+
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+ // end copy stuff
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||
+ {
|
||||
+ if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ if (args.length == 0)
|
||||
+ {
|
||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (SUBCOMMANDS.contains(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
+ {
|
||||
+ if (!testPermission(sender, args[0].toLowerCase(Locale.ENGLISH))) return true;
|
||||
+ }
|
||||
+ switch (args[0].toLowerCase(Locale.ENGLISH))
|
||||
+ {
|
||||
+ case "reload":
|
||||
+ doReload(sender);
|
||||
+ break;
|
||||
+ case "ver":
|
||||
+ if (!testPermission(sender, "version"))
|
||||
+ break; // "ver" needs a special check because it's an alias. All other commands are checked up before the switch statement (because they are present in the SUBCOMMANDS set)
|
||||
+ case "version":
|
||||
+ Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ if (ver != null)
|
||||
+ {
|
||||
+ ver.execute(sender, commandLabel, new String[0]);
|
||||
+ break;
|
||||
+ }
|
||||
+ // else - fall through to default
|
||||
+ default:
|
||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void doReload(CommandSender sender)
|
||||
+ {
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||
+
|
||||
+ MinecraftServer console = MinecraftServer.getServer();
|
||||
+ ScissorsConfig.init((File) console.options.valueOf("scissors-settings"));
|
||||
+ console.server.reloadCount++;
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Scissors config reload complete.");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e08f502fc7165f9f466217910210edb5059d39a8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
@@ -0,0 +1,199 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.InvocationTargetException;
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.regex.Pattern;
|
||||
+
|
||||
+// TODO - Migrate to new format
|
||||
+public class ScissorsConfig
|
||||
+{
|
||||
+
|
||||
+ private static final String HEADER = """
|
||||
+ This is the main configuration file for Scissors.
|
||||
+ As you can see, there's tons to configure. Some options may impact gameplay, so use
|
||||
+ with caution, and make sure you know what each option does before configuring.
|
||||
+
|
||||
+ If you need help with the configuration or have any questions related to Scissors,
|
||||
+ join us in our Discord.
|
||||
+
|
||||
+ Discord: https://discord.com/invite/mtVQcHn58h
|
||||
+ Website: https://scissors.gg/\s
|
||||
+ Docs: https://scissors.gg/javadoc/1.19/\s
|
||||
+ """;
|
||||
+ private static final Pattern SPACE = Pattern.compile(" ");
|
||||
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
||||
+ /*========================================================================*/
|
||||
+ public static YamlConfiguration config;
|
||||
+ static int version;
|
||||
+ /*========================================================================*/
|
||||
+ static Map<String, Command> commands;
|
||||
+ private static File CONFIG_FILE;
|
||||
+
|
||||
+ public static void init(File configFile)
|
||||
+ {
|
||||
+ final File configFolder = (File) DedicatedServer.getServer().options.valueOf("scissors-settings" + "-directory");
|
||||
+ final Path configFolderPath = configFolder.toPath();
|
||||
+ final Path oldConfigFilePath = configFile.toPath();
|
||||
+ final Path newConfigFilePath = configFolderPath.resolve(configFile.toPath());
|
||||
+
|
||||
+ if (configFile.exists())
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ Files.move(oldConfigFilePath, newConfigFilePath);
|
||||
+ }
|
||||
+ catch (IOException e)
|
||||
+ {
|
||||
+ throw new RuntimeException("Error migrating configuration file to new directory!", e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ CONFIG_FILE = newConfigFilePath.toFile();
|
||||
+ config = new YamlConfiguration();
|
||||
+ try
|
||||
+ {
|
||||
+ config.load(CONFIG_FILE);
|
||||
+ }
|
||||
+ catch (IOException ex)
|
||||
+ {
|
||||
+ }
|
||||
+ catch (InvalidConfigurationException ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load scissors.yml, please correct your syntax errors", ex);
|
||||
+ throw Throwables.propagate(ex);
|
||||
+ }
|
||||
+
|
||||
+ commands = new HashMap<>();
|
||||
+ commands.put("scissors", new ScissorsCommand("scissors"));
|
||||
+
|
||||
+ config.options().header(HEADER);
|
||||
+ config.options().copyDefaults(true);
|
||||
+
|
||||
+ version = getInt("config-version", 1);
|
||||
+ set("config-version", 1);
|
||||
+ readConfig(ScissorsConfig.class, null);
|
||||
+ }
|
||||
+
|
||||
+ protected static void logError(String s)
|
||||
+ {
|
||||
+ Bukkit.getLogger().severe(s);
|
||||
+ }
|
||||
+
|
||||
+ protected static void fatal(String s)
|
||||
+ {
|
||||
+ throw new RuntimeException("Fatal scissors.yml config error: " + s);
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands()
|
||||
+ {
|
||||
+ for (Map.Entry<String, Command> entry : commands.entrySet())
|
||||
+ {
|
||||
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Scissors", entry.getValue());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ static void readConfig(Class<?> clazz, Object instance)
|
||||
+ {
|
||||
+ for (Method method : clazz.getDeclaredMethods())
|
||||
+ {
|
||||
+ if (Modifier.isPrivate(method.getModifiers()))
|
||||
+ {
|
||||
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE)
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ method.setAccessible(true);
|
||||
+ method.invoke(instance);
|
||||
+ }
|
||||
+ catch (InvocationTargetException ex)
|
||||
+ {
|
||||
+ throw Throwables.propagate(ex.getCause());
|
||||
+ }
|
||||
+ catch (Exception ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ saveConfig();
|
||||
+ }
|
||||
+
|
||||
+ static void saveConfig()
|
||||
+ {
|
||||
+ try
|
||||
+ {
|
||||
+ config.save(CONFIG_FILE);
|
||||
+ }
|
||||
+ catch (IOException ex)
|
||||
+ {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static boolean runCommandsInBooks = false;
|
||||
+
|
||||
+ private static void runCommandsInBooks() {
|
||||
+ runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||
+ }
|
||||
+
|
||||
+ private static void set(String path, Object val)
|
||||
+ {
|
||||
+ config.set(path, val);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean getBoolean(String path, boolean def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getBoolean(path, config.getBoolean(path));
|
||||
+ }
|
||||
+
|
||||
+ private static double getDouble(String path, double def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getDouble(path, config.getDouble(path));
|
||||
+ }
|
||||
+
|
||||
+ private static float getFloat(String path, float def)
|
||||
+ {
|
||||
+ // TODO: Figure out why getFloat() always returns the default value.
|
||||
+ return (float) getDouble(path, def);
|
||||
+ }
|
||||
+
|
||||
+ private static int getInt(String path, int def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getInt(path, config.getInt(path));
|
||||
+ }
|
||||
+
|
||||
+ private static <T> List getList(String path, T def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getList(path, config.getList(path));
|
||||
+ }
|
||||
+
|
||||
+ private static String getString(String path, String def)
|
||||
+ {
|
||||
+ config.addDefault(path, def);
|
||||
+ return config.getString(path, config.getString(path));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 31faf2d6492696f7d0c99a48edbc0d6f15db1209..d6d3e802648eaf001f6e8143a361053ab41c5291 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -121,6 +121,7 @@ public class Main {
|
||||
// Paper start - load config files for access below if needed
|
||||
org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings"));
|
||||
org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings"));
|
||||
+ org.bukkit.configuration.file.YamlConfiguration scissorsConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("scissors-settings")); // Scissors - TODO Change this
|
||||
// Paper end
|
||||
|
||||
Path path1 = Paths.get("eula.txt");
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 51b3db0b6c2cede95b584268e035c0fb36d38094..f8e49559657c1a2788a3aa8a15df6da7491c3fda 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -221,7 +221,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||
// Paper end
|
||||
-
|
||||
+ // Scissors start
|
||||
+ try {
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.init((java.io.File) options.valueOf("scissors-settings"));
|
||||
+ } catch (Exception e) {
|
||||
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands();
|
||||
+ // Scissors end
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
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 653c34ae4a5f55773f0c4af54c8cbb426ddb7d7b..9a2ed55bc6837875adfbf623b1cabf605801d5b4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -978,6 +978,8 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.init(((File) console.options.valueOf("scissors-settings"))); // Scissors
|
||||
+
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
@@ -1009,6 +1011,7 @@ public final class CraftServer implements Server {
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands(); // Scissors
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -2760,6 +2763,12 @@ public final class CraftServer implements Server {
|
||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public YamlConfiguration getScissorsConfig()
|
||||
+ {
|
||||
+ return me.totalfreedom.scissors.ScissorsConfig.config;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
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 21db4153a9eb5e52ff357b4146ae4302029d5cd5..f5b5eb6686684791c281604bd308107427861af2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -173,6 +173,22 @@ public class Main {
|
||||
.defaultsTo("Unknown Server")
|
||||
.describedAs("Name");
|
||||
// Paper end
|
||||
+
|
||||
+ // Scissors start
|
||||
+ acceptsAll(asList("scissors-dir", "scissors-settings-directory"), "Directory for Scissors settings")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
|
||||
+ .describedAs("Config directory");
|
||||
+ // Scissors end
|
||||
+
|
||||
+ // Scissors start
|
||||
+ acceptsAll(asList("scissors", "scissors-settings"), "File for scissors settings")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File("scissors.yml"))
|
||||
+ .describedAs("Yml file");
|
||||
+ // Scissors end
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,96 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:29:03 +0100
|
||||
Subject: [PATCH] Disable running commands in books by default
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
index e08f502fc7165f9f466217910210edb5059d39a8..1aa418ef5e400aabdf17dbe81da6cee6a1f63d96 100644
|
||||
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
@@ -151,7 +151,8 @@ public class ScissorsConfig
|
||||
|
||||
public static boolean runCommandsInBooks = false;
|
||||
|
||||
- private static void runCommandsInBooks() {
|
||||
+ private static void runCommandsInBooks()
|
||||
+ {
|
||||
runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
index 31911c09fe15753ae32fa39417bdc9e9de552a88..8ef33e2e2374c456cb9d4aab8ed6f1742951f402 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world.item;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -9,8 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.ComponentUtils;
|
||||
+import net.minecraft.network.chat.*;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -111,8 +112,7 @@ public class WrittenBookItem extends Item {
|
||||
|
||||
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
|
||||
CompoundTag compoundTag = book.getTag();
|
||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper
|
||||
- compoundTag.putBoolean("resolved", true);
|
||||
+ if (compoundTag != null) { // Paper
|
||||
if (!makeSureTagIsValid(compoundTag)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -161,8 +161,41 @@ public class WrittenBookItem extends Item {
|
||||
component2 = Component.literal(text);
|
||||
}
|
||||
|
||||
- return Component.Serializer.toJson(component2);
|
||||
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
|
||||
+ }
|
||||
+
|
||||
+ // Scissors start - Allow server owners to disable run command in books
|
||||
+ public static Component sanitize(Component component, int depth) {
|
||||
+ if (depth > 128) {
|
||||
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
|
||||
+ }
|
||||
+
|
||||
+ MutableComponent component2 = component.copy();
|
||||
+
|
||||
+ final Style style = component2.getStyle();
|
||||
+ final ClickEvent clickEvent = style.getClickEvent();
|
||||
+
|
||||
+ if(clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
|
||||
+ {
|
||||
+ final String clickEventValue = clickEvent.getValue();
|
||||
+
|
||||
+ component2 = component2.copy().setStyle(style
|
||||
+ .withClickEvent(null)
|
||||
+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran": "said") + ": " + clickEvent.getValue())))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ final List<Component> processedExtra = component2.getSiblings()
|
||||
+ .stream()
|
||||
+ .map(comp -> sanitize(comp, depth + 1))
|
||||
+ .toList();
|
||||
+
|
||||
+ component2.getSiblings().clear();
|
||||
+ component2.getSiblings().addAll(processedExtra);
|
||||
+
|
||||
+ return component2;
|
||||
}
|
||||
+ // Scissors end
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 11 Jul 2022 17:29:12 -0300
|
||||
Subject: [PATCH] Validate block 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 53a71e699e885aa36fcc07f04fb5f15e4661b7f2..f54a8732d30590225ac986f05a08f4a40b2ae18c 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1364,7 +1364,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@Override
|
||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (this.player.hasPermissions(2)) {
|
||||
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions
|
||||
BlockEntity tileentity = this.player.getLevel().getBlockEntity(packet.getPos());
|
||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||
|
@ -0,0 +1,93 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 13 Jul 2022 12:13:22 +0100
|
||||
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
index 1aa418ef5e400aabdf17dbe81da6cee6a1f63d96..9cd5ffca69df27f794f5a72e687fc6b3ae0f1656 100644
|
||||
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||
@@ -87,8 +87,8 @@ public class ScissorsConfig
|
||||
config.options().header(HEADER);
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
- version = getInt("config-version", 1);
|
||||
- set("config-version", 1);
|
||||
+ version = getInt("config-version", 2);
|
||||
+ set("config-version", 2);
|
||||
readConfig(ScissorsConfig.class, null);
|
||||
}
|
||||
|
||||
@@ -156,6 +156,13 @@ public class ScissorsConfig
|
||||
runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||
}
|
||||
|
||||
+ // people still may want them to bypass permissions for warps
|
||||
+ public static boolean commandSignsBypassPermissions = false;
|
||||
+ private static void commandSignsBypassPermissions()
|
||||
+ {
|
||||
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
||||
+ }
|
||||
+
|
||||
private static void set(String path, Object val)
|
||||
{
|
||||
config.set(path, val);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index 4da4edae517a0efec6e03a719ec47b700509dab1..1ec83cbfc2860e1153be301eefb628e209bf9186 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
@@ -15,6 +17,7 @@ import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
@@ -24,6 +27,8 @@ import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
|
||||
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
||||
private static final boolean CONVERT_LEGACY_SIGNS = Boolean.getBoolean("convertLegacySigns"); // Paper
|
||||
@@ -270,7 +275,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
if (!event.callEvent()) {
|
||||
return false;
|
||||
}
|
||||
- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
|
||||
+
|
||||
+ // Scissors start - Add optional permissions to command signs
|
||||
+ final MinecraftServer vanillaServer = player.getServer();
|
||||
+ final CraftServer craftServer = vanillaServer.server;
|
||||
+ final CraftPlayer craftPlayer = player.getBukkitEntity();
|
||||
+ final Commands commands = vanillaServer.getCommands();
|
||||
+
|
||||
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
||||
+ {
|
||||
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
|
||||
+ } else
|
||||
+ {
|
||||
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
||||
+ }
|
||||
+ // Scissors end
|
||||
// Paper end
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 16 Aug 2022 17:13:02 +0100
|
||||
Subject: [PATCH] Refuse to convert legacy messages over 1k characters
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..6f036df37609daf33db3884174406e1ccd339735 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -3,12 +3,14 @@ package org.bukkit.craftbukkit.util;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.gson.JsonParseException;
|
||||
+
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
+
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ClickEvent.Action;
|
||||
@@ -199,6 +201,11 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
||||
+ // Scissors start - Refuse to convert legacy messages over 1k characters
|
||||
+ if (message.length() > 1_000) {
|
||||
+ return new Component[]{Component.empty()};
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return new StringMessage(message, keepNewlines, plain).getOutput();
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Mon, 22 Aug 2022 21:33:37 -0500
|
||||
Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
index 334a47b5e0d205c57dfcbb17168cbd3f21d15606..0227f4ed153d229747722ab709932741e0998dc1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||
@@ -270,6 +270,13 @@ public abstract class HangingEntity extends Entity {
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
BlockPos blockposition = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
||||
|
||||
+ // Scissors start - Fixes exploit where bad TileX, TileY, and TileZ coordinates can crash servers
|
||||
+ if (level.isLoadedAndInBounds(blockposition))
|
||||
+ {
|
||||
+ this.pos = blockposition;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (!blockposition.closerThan(this.blockPosition(), 16.0D)) {
|
||||
HangingEntity.LOGGER.error("Hanging entity at invalid position: {}", blockposition);
|
||||
} else {
|
86
patches/server/0040-Prevent-velocity-freeze.patch
Normal file
86
patches/server/0040-Prevent-velocity-freeze.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 27 Nov 2022 05:14:18 +0000
|
||||
Subject: [PATCH] Prevent velocity freeze
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
index d73c10167c9100615cd5180f5e5d09b00f7bdc2a..569d0eb30f3f8043197254bceaa4a702110d5e7c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
@@ -42,9 +42,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
if (d6 != 0.0D) {
|
||||
- this.xPower = d3 / d6 * 0.1D;
|
||||
- this.yPower = d4 / d6 * 0.1D;
|
||||
- this.zPower = d5 / d6 * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = d3 / d6 * 0.1D;
|
||||
+ //this.yPower = d4 / d6 * 0.1D;
|
||||
+ //this.zPower = d5 / d6 * 0.1D;
|
||||
+ // Scissors end
|
||||
+
|
||||
+ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -151,6 +155,25 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower}));
|
||||
}
|
||||
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ public void setPower(double xPower, double yPower, double zPower)
|
||||
+ {
|
||||
+ if (Double.isInfinite(xPower) || Double.isInfinite(yPower) || Double.isInfinite(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (Double.isNaN(xPower) || Double.isNaN(yPower) || Double.isNaN(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.xPower = xPower;
|
||||
+ this.yPower = yPower;
|
||||
+ this.zPower = zPower;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
@@ -158,9 +181,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
ListTag nbttaglist = nbt.getList("power", 6);
|
||||
|
||||
if (nbttaglist.size() == 3) {
|
||||
- this.xPower = nbttaglist.getDouble(0);
|
||||
- this.yPower = nbttaglist.getDouble(1);
|
||||
- this.zPower = nbttaglist.getDouble(2);
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = nbttaglist.getDouble(0);
|
||||
+ //this.yPower = nbttaglist.getDouble(1);
|
||||
+ //this.zPower = nbttaglist.getDouble(2);
|
||||
+ // Scissors end
|
||||
+
|
||||
+ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,9 +221,12 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
Vec3 vec3d = entity.getLookAngle();
|
||||
|
||||
this.setDeltaMovement(vec3d);
|
||||
- this.xPower = vec3d.x * 0.1D;
|
||||
- this.yPower = vec3d.y * 0.1D;
|
||||
- this.zPower = vec3d.z * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = vec3d.x * 0.1D;
|
||||
+ //this.yPower = vec3d.y * 0.1D;
|
||||
+ //this.zPower = vec3d.z * 0.1D;
|
||||
+ setPower(vec3d.x * 0.1D, vec3d.y * 0.1D, vec3d.z * 0.1D);
|
||||
+ // Scissors end
|
||||
this.setOwner(entity);
|
||||
}
|
||||
|
Reference in New Issue
Block a user