From db22a6b194453bd9e0b18b0463c6882e5e7c2754 Mon Sep 17 00:00:00 2001 From: Luna <90072930+LunaWasFlaggedAgain@users.noreply.github.com> Date: Mon, 10 Apr 2023 21:08:03 -0300 Subject: [PATCH] Patch 2 crash exploits (#78) * Limit projectile velocity to 1024 * Limit sculk catalyst cursor positions --- .../server/0036-Prevent-velocity-freeze.patch | 23 +++++++++++------- ...imit-sculk-catalyst-cursor-positions.patch | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 patches/server/0041-Limit-sculk-catalyst-cursor-positions.patch diff --git a/patches/server/0036-Prevent-velocity-freeze.patch b/patches/server/0036-Prevent-velocity-freeze.patch index b839501..5c807b4 100644 --- a/patches/server/0036-Prevent-velocity-freeze.patch +++ b/patches/server/0036-Prevent-velocity-freeze.patch @@ -5,10 +5,17 @@ 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 2096e8a0bdbcfc865f175f3a01ab688542481531..1c31e2c457c416a970b6ff4913c63195ff19443a 100644 +index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638eba6f8d0 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java -@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -1,5 +1,6 @@ + package net.minecraft.world.entity.projectile; + ++import me.totalfreedom.scissors.MathUtility; + import net.minecraft.core.particles.ParticleOptions; + import net.minecraft.core.particles.ParticleTypes; + import net.minecraft.nbt.CompoundTag; +@@ -41,9 +42,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); if (d6 != 0.0D) { @@ -25,7 +32,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..1c31e2c457c416a970b6ff4913c63195 } } -@@ -141,6 +145,25 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -141,6 +146,25 @@ public abstract class AbstractHurtingProjectile extends Projectile { nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower})); } @@ -42,16 +49,16 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..1c31e2c457c416a970b6ff4913c63195 + return; + } + -+ this.xPower = xPower; -+ this.yPower = yPower; -+ this.zPower = zPower; ++ this.xPower = MathUtility.clampDouble(xPower, -1024, 1024); ++ this.yPower = MathUtility.clampDouble(yPower, -1024, 1024); ++ this.zPower = MathUtility.clampDouble(zPower, -1024, 1024); + } + // Scissors end + @Override public void readAdditionalSaveData(CompoundTag nbt) { super.readAdditionalSaveData(nbt); -@@ -148,9 +171,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -148,9 +172,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { ListTag nbttaglist = nbt.getList("power", 6); if (nbttaglist.size() == 3) { @@ -68,7 +75,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..1c31e2c457c416a970b6ff4913c63195 } } -@@ -184,9 +211,12 @@ public abstract class AbstractHurtingProjectile extends Projectile { +@@ -184,9 +212,12 @@ public abstract class AbstractHurtingProjectile extends Projectile { Vec3 vec3d = entity.getLookAngle(); this.setDeltaMovement(vec3d); diff --git a/patches/server/0041-Limit-sculk-catalyst-cursor-positions.patch b/patches/server/0041-Limit-sculk-catalyst-cursor-positions.patch new file mode 100644 index 0000000..c4c51c5 --- /dev/null +++ b/patches/server/0041-Limit-sculk-catalyst-cursor-positions.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luna +Date: Mon, 10 Apr 2023 13:56:18 -0300 +Subject: [PATCH] Limit sculk catalyst cursor positions + + +diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java +index ab732f0e52ef3c3d3be6ddc827d693fe294e4167..761c8cfb98e05a3c500599520e26e4323725fc85 100644 +--- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java ++++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java +@@ -141,6 +141,13 @@ public class SculkSpreader { + Object2IntMap object2IntMap = new Object2IntOpenHashMap<>(); + + for(SculkSpreader.ChargeCursor chargeCursor : this.cursors) { ++ // Scissors start ++ if (!world.getMinecraftWorld().isLoadedAndInBounds(chargeCursor.getPos())) ++ { ++ continue; ++ } ++ // Scissors end ++ + chargeCursor.update(world, pos, random, this, shouldConvertToBlock); + if (chargeCursor.charge <= 0) { + world.levelEvent(3006, chargeCursor.getPos(), 0);