mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
add regular 1.20.4 patches
This commit is contained in:
parent
488e1c3dc2
commit
6423b04da8
@ -2,7 +2,7 @@ group=me.totalfreedom.scissors
|
|||||||
version=1.20.4-R0.1-SNAPSHOT
|
version=1.20.4-R0.1-SNAPSHOT
|
||||||
|
|
||||||
mcVersion=1.20.4
|
mcVersion=1.20.4
|
||||||
paperRef=b4c9e7e5d40fd4a0a7fea270fd4ebb72b38fa0fc
|
paperRef=5e978d3a3d2c8068ea152ea5a38938f1f8c15d94
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
@ -1873,8 +1873,44 @@ index 0000000000000000000000000000000000000000..3500005bb09dc484bc333f1e0799613d
|
|||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
\ No newline at end of file
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/poi/PoiChunk.java b/src/main/java/io/papermc/paper/chunk/system/poi/PoiChunk.java
|
||||||
|
index d72041aa814ff179e6e29a45dcd359a91d426d47..9c16cd0728d2252cf4dadb45779e2ad0e8ca4c0e 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/system/poi/PoiChunk.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/system/poi/PoiChunk.java
|
||||||
|
@@ -18,7 +18,7 @@ import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
-public final class PoiChunk {
|
||||||
|
+public class PoiChunk {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||||
|
index abd0217cf0bff183c8e262edc173a53403797c1a..42170127cc1ed35cb2aec6bf7eb473a0137c63bb 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||||
|
@@ -165,7 +165,8 @@ public final class ChunkHolderManager {
|
||||||
|
return this.chunkHolders.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
- public void close(final boolean save, final boolean halt) {
|
||||||
|
+ public void close(boolean save, final boolean halt) { // ASWM
|
||||||
|
+ if (this.world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance) save = false; // ASWM
|
||||||
|
TickThread.ensureTickThread("Closing world off-main");
|
||||||
|
if (halt) {
|
||||||
|
LOGGER.info("Waiting 60s for chunk system to halt for world '" + this.world.getWorld().getName() + "'");
|
||||||
|
@@ -1316,7 +1317,7 @@ public final class ChunkHolderManager {
|
||||||
|
|
||||||
|
public boolean processTicketUpdates() {
|
||||||
|
co.aikar.timings.MinecraftTimings.distanceManagerTick.startTiming(); try { // Paper - add timings for distance manager
|
||||||
|
- return this.processTicketUpdates(true, true, null);
|
||||||
|
+ return this.processTicketUpdates(true, true, null);
|
||||||
|
} finally { co.aikar.timings.MinecraftTimings.distanceManagerTick.stopTiming(); } // Paper - add timings for distance manager
|
||||||
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||||
index e7fb084ddb88ab62f1d493a999cc82b9258d275e..b84fabc22e54ca56da08e7e6fb2b2b8d2f3be66c 100644
|
index e7fb084ddb88ab62f1d493a999cc82b9258d275e..943cdd570c9e5c87ee9f3984404e08b4cdffeca0 100644
|
||||||
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||||
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||||
@@ -6,6 +6,7 @@ import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock;
|
@@ -6,6 +6,7 @@ import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock;
|
||||||
@ -1896,7 +1932,7 @@ index e7fb084ddb88ab62f1d493a999cc82b9258d275e..b84fabc22e54ca56da08e7e6fb2b2b8d
|
|||||||
|
|
||||||
private volatile boolean cancelled;
|
private volatile boolean cancelled;
|
||||||
private NewChunkHolder.GenericDataLoadTaskCallback entityLoadTask;
|
private NewChunkHolder.GenericDataLoadTaskCallback entityLoadTask;
|
||||||
@@ -45,11 +46,19 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
@@ -45,11 +46,20 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
||||||
final NewChunkHolder chunkHolder, final PrioritisedExecutor.Priority priority) {
|
final NewChunkHolder chunkHolder, final PrioritisedExecutor.Priority priority) {
|
||||||
super(scheduler, world, chunkX, chunkZ);
|
super(scheduler, world, chunkX, chunkZ);
|
||||||
this.chunkHolder = chunkHolder;
|
this.chunkHolder = chunkHolder;
|
||||||
@ -1907,6 +1943,7 @@ index e7fb084ddb88ab62f1d493a999cc82b9258d275e..b84fabc22e54ca56da08e7e6fb2b2b8d
|
|||||||
- });
|
- });
|
||||||
+ // ASWM start
|
+ // ASWM start
|
||||||
+ if (world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance levelInstance) {
|
+ if (world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance levelInstance) {
|
||||||
|
+
|
||||||
+ this.loadTask = levelInstance.getLoadTask(this, scheduler, world, chunkX, chunkZ, priority, result -> {
|
+ this.loadTask = levelInstance.getLoadTask(this, scheduler, world, chunkX, chunkZ, priority, result -> {
|
||||||
+ ChunkLoadTask.this.complete(result == null ? null : result.left(), result == null ? null : result.right());
|
+ ChunkLoadTask.this.complete(result == null ? null : result.left(), result == null ? null : result.right());
|
||||||
+ });
|
+ });
|
||||||
@ -1921,7 +1958,7 @@ index e7fb084ddb88ab62f1d493a999cc82b9258d275e..b84fabc22e54ca56da08e7e6fb2b2b8d
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tryCompleteLoad() {
|
private void tryCompleteLoad() {
|
||||||
@@ -274,7 +283,7 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
@@ -274,7 +284,7 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1990,7 +2027,7 @@ index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..d6f329f4c9534d45533774ad2fadec70
|
|||||||
String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||||
String name = (dimensionKey == LevelStem.OVERWORLD) ? s : s + "_" + worldType;
|
String name = (dimensionKey == LevelStem.OVERWORLD) ? s : s + "_" + worldType;
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5176e32719d6192119bc53961527fe4f698e01bd 100644
|
index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..869bb52fbdc4a5a96324e3cf5b6a3cd51a8870cb 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||||
@@ -165,7 +165,11 @@ public class ServerChunkCache extends ChunkSource {
|
@@ -165,7 +165,11 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
@ -2006,27 +2043,199 @@ index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..5176e32719d6192119bc53961527fe4f
|
|||||||
this.level = world;
|
this.level = world;
|
||||||
this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(world);
|
this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(world);
|
||||||
this.mainThread = Thread.currentThread();
|
this.mainThread = Thread.currentThread();
|
||||||
|
@@ -294,7 +298,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
// Paper end
|
||||||
|
com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info
|
||||||
|
this.level.timings.syncChunkLoad.startTiming(); // Paper
|
||||||
|
- chunkproviderserver_b.managedBlock(completablefuture::isDone);
|
||||||
|
+ chunkproviderserver_b.managedBlock(completablefuture::isDone);
|
||||||
|
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system
|
||||||
|
this.level.timings.syncChunkLoad.stopTiming(); // Paper
|
||||||
|
} // Paper
|
||||||
|
@@ -446,7 +450,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
public void save(boolean flush) {
|
||||||
|
this.runDistanceManagerUpdates();
|
||||||
|
try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings
|
||||||
|
- this.chunkMap.saveAllChunks(flush);
|
||||||
|
+ this.chunkMap.saveAllChunks(flush);
|
||||||
|
} // Paper - Timings
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -516,10 +520,43 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
|
||||||
|
gameprofilerfiller.push("pollingChunks");
|
||||||
|
gameprofilerfiller.push("filteringLoadedChunks");
|
||||||
|
- // Paper - optimise chunk tick iteration
|
||||||
|
if (this.level.getServer().tickRateManager().runsNormally()) this.level.timings.chunkTicks.startTiming(); // Paper
|
||||||
|
|
||||||
|
- // Paper - optimise chunk tick iteration
|
||||||
|
+ // Paper start - optimise chunk tick iteration
|
||||||
|
+ ChunkMap playerChunkMap = this.chunkMap;
|
||||||
|
+ for (ServerPlayer player : this.level.players) {
|
||||||
|
+ if (!player.affectsSpawning || player.isSpectator()) {
|
||||||
|
+ playerChunkMap.playerMobSpawnMap.remove(player);
|
||||||
|
+ player.playerNaturallySpawnedEvent = null;
|
||||||
|
+ player.lastEntitySpawnRadiusSquared = -1.0;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int viewDistance = io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player);
|
||||||
|
+
|
||||||
|
+ // copied and modified from isOutisdeRange
|
||||||
|
+ int chunkRange = (int)level.spigotConfig.mobSpawnRange;
|
||||||
|
+ chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange;
|
||||||
|
+ chunkRange = (chunkRange > DistanceManager.MOB_SPAWN_RANGE) ? DistanceManager.MOB_SPAWN_RANGE : chunkRange;
|
||||||
|
+
|
||||||
|
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
|
||||||
|
+ event.callEvent();
|
||||||
|
+ if (event.isCancelled() || event.getSpawnRadius() < 0) {
|
||||||
|
+ playerChunkMap.playerMobSpawnMap.remove(player);
|
||||||
|
+ player.playerNaturallySpawnedEvent = null;
|
||||||
|
+ player.lastEntitySpawnRadiusSquared = -1.0;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range
|
||||||
|
+ int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
|
||||||
|
+ int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ());
|
||||||
|
+
|
||||||
|
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
|
||||||
|
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
|
||||||
|
+ player.playerNaturallySpawnedEvent = event;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - optimise chunk tick iteration
|
||||||
|
|
||||||
|
if (this.level.getServer().tickRateManager().runsNormally()) {
|
||||||
|
gameprofilerfiller.popPush("naturalSpawnCount");
|
||||||
|
@@ -555,7 +592,6 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||||
|
|
||||||
|
// Paper start - optimise chunk tick iteration
|
||||||
|
- ChunkMap playerChunkMap = this.chunkMap;
|
||||||
|
for (ServerPlayer player : this.level.players) {
|
||||||
|
if (!player.affectsSpawning || player.isSpectator()) {
|
||||||
|
playerChunkMap.playerMobSpawnMap.remove(player);
|
||||||
|
@@ -591,7 +627,6 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
// Paper end - optimise chunk tick iteration
|
||||||
|
int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||||
|
boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
|
||||||
|
- // Paper - optimise chunk tick iteration
|
||||||
|
|
||||||
|
int chunksTicked = 0; // Paper
|
||||||
|
// Paper start - optimise chunk tick iteration
|
||||||
|
@@ -609,48 +644,48 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
chunkIterator = shuffled.iterator();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
- // Paper end - optimise chunk tick iteration
|
||||||
|
- while (chunkIterator.hasNext()) {
|
||||||
|
- LevelChunk chunk1 = chunkIterator.next();
|
||||||
|
// Paper end - optimise chunk tick iteration
|
||||||
|
- ChunkPos chunkcoordintpair = chunk1.getPos();
|
||||||
|
+ while (chunkIterator.hasNext()) {
|
||||||
|
+ LevelChunk chunk1 = chunkIterator.next(); // Paper - optimise chunk tick iteration
|
||||||
|
+ ChunkPos chunkcoordintpair = chunk1.getPos();
|
||||||
|
|
||||||
|
- // Paper start - optimise chunk tick iteration
|
||||||
|
- com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersNearby
|
||||||
|
- = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE);
|
||||||
|
- if (playersNearby == null) {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- Object[] rawData = playersNearby.getRawData();
|
||||||
|
- boolean spawn = false;
|
||||||
|
- boolean tick = false;
|
||||||
|
- for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) {
|
||||||
|
- ServerPlayer player = (ServerPlayer)rawData[itr];
|
||||||
|
- if (player.isSpectator()) {
|
||||||
|
+ // Paper start - optimise chunk tick iteration
|
||||||
|
+ com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> playersNearby
|
||||||
|
+ = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE);
|
||||||
|
+ if (playersNearby == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
- double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player);
|
||||||
|
- spawn |= player.lastEntitySpawnRadiusSquared >= distance;
|
||||||
|
- tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance;
|
||||||
|
- if (spawn & tick) {
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) {
|
||||||
|
- // Paper end - optimise chunk tick iteration
|
||||||
|
- chunk1.incrementInhabitedTime(j);
|
||||||
|
- if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
|
||||||
|
- NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||||
|
+ Object[] rawData = playersNearby.getRawData();
|
||||||
|
+ boolean spawn = false;
|
||||||
|
+ boolean tick = false;
|
||||||
|
+ for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) {
|
||||||
|
+ ServerPlayer player = (ServerPlayer)rawData[itr];
|
||||||
|
+ if (player.isSpectator()) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player);
|
||||||
|
+ spawn |= player.lastEntitySpawnRadiusSquared >= distance;
|
||||||
|
+ tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance;
|
||||||
|
+ if (spawn & tick) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+ if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) {
|
||||||
|
+ // Paper end - optimise chunk tick iteration
|
||||||
|
+ chunk1.incrementInhabitedTime(j);
|
||||||
|
+ if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
|
||||||
|
+ NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration
|
||||||
|
- this.level.tickChunk(chunk1, l);
|
||||||
|
- if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
|
||||||
|
+ if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration
|
||||||
|
+ this.level.tickChunk(chunk1, l);
|
||||||
|
+ if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
- // Paper start - optimise chunk tick iteration
|
||||||
|
+ // Paper start - optimise chunk tick iteration
|
||||||
|
} finally {
|
||||||
|
if (chunkIterator instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
|
||||||
|
safeIterator.finishedIterating();
|
||||||
|
@@ -662,14 +697,14 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
gameprofilerfiller.popPush("customSpawners");
|
||||||
|
if (flag) {
|
||||||
|
try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings
|
||||||
|
- this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
||||||
|
+ this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
||||||
|
} // Paper - timings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameprofilerfiller.popPush("broadcast");
|
||||||
|
// Paper - optimise chunk tick iteration
|
||||||
|
- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
|
||||||
|
+ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
|
||||||
|
// Paper start - optimise chunk tick iteration
|
||||||
|
if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) {
|
||||||
|
it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone();
|
||||||
|
@@ -683,7 +718,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Paper end - optimise chunk tick iteration
|
||||||
|
- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
|
||||||
|
+ this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
|
||||||
|
// Paper - optimise chunk tick iteration
|
||||||
|
gameprofilerfiller.pop();
|
||||||
|
gameprofilerfiller.pop();
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979a82740a1 100644
|
index 6041f1f5151f26d389f946d70f16e1de76db496b..9c2a2e441eb7efeee0caaec442158a66acfe8cc6 100644
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -39,7 +39,6 @@ import java.util.stream.Stream;
|
@@ -319,7 +319,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.CrashReport;
|
|
||||||
-import net.minecraft.CrashReportCategory;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
@@ -83,7 +82,6 @@ import net.minecraft.util.valueproviders.IntProvider;
|
|
||||||
import net.minecraft.util.valueproviders.UniformInt;
|
|
||||||
import net.minecraft.world.DifficultyInstance;
|
|
||||||
import net.minecraft.world.RandomSequences;
|
|
||||||
-import net.minecraft.world.TickRateManager;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
@@ -319,7 +317,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
java.util.function.Consumer<net.minecraft.world.level.chunk.ChunkAccess> consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> {
|
java.util.function.Consumer<net.minecraft.world.level.chunk.ChunkAccess> consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> {
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
synchronized (ret) { // Folia - region threading - make callback thread-safe TODO rebase
|
synchronized (ret) { // Folia - region threading - make callback thread-safe TODO rebase
|
||||||
@ -2035,7 +2244,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
} // Folia - region threading - make callback thread-safe TODO rebase
|
} // Folia - region threading - make callback thread-safe TODO rebase
|
||||||
chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier);
|
chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier);
|
||||||
}
|
}
|
||||||
@@ -689,6 +687,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -689,6 +689,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
|
||||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||||
@ -2050,7 +2259,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
||||||
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error
|
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error
|
||||||
|
|
||||||
@@ -727,6 +733,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -727,6 +735,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@ -2063,7 +2272,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||||
this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||||
@@ -738,7 +750,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -738,7 +752,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
//PersistentEntitySectionManager persistententitysectionmanager = this.entityManager; // Paper - rewrite chunk system
|
//PersistentEntitySectionManager persistententitysectionmanager = this.entityManager; // Paper - rewrite chunk system
|
||||||
|
|
||||||
//Objects.requireNonNull(this.entityManager); // Paper - rewrite chunk system
|
//Objects.requireNonNull(this.entityManager); // Paper - rewrite chunk system
|
||||||
@ -2072,7 +2281,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
return minecraftserver.overworld().getDataStorage();
|
return minecraftserver.overworld().getDataStorage();
|
||||||
});
|
});
|
||||||
this.chunkSource.getGeneratorState().ensureStructuresGenerated();
|
this.chunkSource.getGeneratorState().ensureStructuresGenerated();
|
||||||
@@ -786,6 +798,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -786,6 +800,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
this.dragonFight = enderDragonFight;
|
this.dragonFight = enderDragonFight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2085,99 +2294,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
public void setWeatherParameters(int clearDuration, int rainDuration, boolean raining, boolean thundering) {
|
public void setWeatherParameters(int clearDuration, int rainDuration, boolean raining, boolean thundering) {
|
||||||
this.serverLevelData.setClearWeatherTime(clearDuration);
|
this.serverLevelData.setClearWeatherTime(clearDuration);
|
||||||
this.serverLevelData.setRainTime(rainDuration);
|
this.serverLevelData.setRainTime(rainDuration);
|
||||||
@@ -807,16 +825,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -1023,14 +1043,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
ProfilerFiller gameprofilerfiller = this.getProfiler();
|
|
||||||
|
|
||||||
this.handlingTick = true;
|
|
||||||
- TickRateManager tickratemanager = this.tickRateManager();
|
|
||||||
- boolean flag = tickratemanager.runsNormally();
|
|
||||||
-
|
|
||||||
- if (flag) {
|
|
||||||
- gameprofilerfiller.push("world border");
|
|
||||||
- this.getWorldBorder().tick();
|
|
||||||
- gameprofilerfiller.popPush("weather");
|
|
||||||
- this.advanceWeatherCycle();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
+ gameprofilerfiller.push("world border");
|
|
||||||
+ this.getWorldBorder().tick();
|
|
||||||
+ gameprofilerfiller.popPush("weather");
|
|
||||||
+ this.advanceWeatherCycle();
|
|
||||||
int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
|
||||||
long j;
|
|
||||||
|
|
||||||
@@ -841,13 +853,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateSkyBrightness();
|
|
||||||
- if (flag) {
|
|
||||||
- this.tickTime();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
+ this.tickTime();
|
|
||||||
gameprofilerfiller.popPush("tickPending");
|
|
||||||
this.timings.scheduledBlocks.startTiming(); // Paper
|
|
||||||
- if (!this.isDebug() && flag) {
|
|
||||||
+ if (!this.isDebug()) {
|
|
||||||
j = this.getGameTime();
|
|
||||||
gameprofilerfiller.push("blockTicks");
|
|
||||||
this.blockTicks.tick(j, 65536, this::tickBlock);
|
|
||||||
@@ -858,35 +867,29 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
this.timings.scheduledBlocks.stopTiming(); // Paper
|
|
||||||
|
|
||||||
gameprofilerfiller.popPush("raid");
|
|
||||||
- if (flag) {
|
|
||||||
- this.timings.raids.startTiming(); // Paper - timings
|
|
||||||
- this.raids.tick();
|
|
||||||
- this.timings.raids.stopTiming(); // Paper - timings
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
+ this.timings.raids.startTiming(); // Paper - timings
|
|
||||||
+ this.raids.tick();
|
|
||||||
+ this.timings.raids.stopTiming(); // Paper - timings
|
|
||||||
gameprofilerfiller.popPush("chunkSource");
|
|
||||||
this.timings.chunkProviderTick.startTiming(); // Paper - timings
|
|
||||||
this.getChunkSource().tick(shouldKeepTicking, true);
|
|
||||||
this.timings.chunkProviderTick.stopTiming(); // Paper - timings
|
|
||||||
gameprofilerfiller.popPush("blockEvents");
|
|
||||||
- if (flag) {
|
|
||||||
- this.timings.doSounds.startTiming(); // Spigot
|
|
||||||
- this.runBlockEvents();
|
|
||||||
- this.timings.doSounds.stopTiming(); // Spigot
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
+ this.timings.doSounds.startTiming(); // Spigot
|
|
||||||
+ this.runBlockEvents();
|
|
||||||
+ this.timings.doSounds.stopTiming(); // Spigot
|
|
||||||
this.handlingTick = false;
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
- boolean flag1 = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
|
||||||
+ boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
|
||||||
|
|
||||||
- if (flag1) {
|
|
||||||
+ if (flag) {
|
|
||||||
this.resetEmptyTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (flag1 || this.emptyTime++ < 300) {
|
|
||||||
+ if (flag || this.emptyTime++ < 300) {
|
|
||||||
gameprofilerfiller.push("entities");
|
|
||||||
this.timings.tickEntities.startTiming(); // Spigot
|
|
||||||
- if (this.dragonFight != null && flag) {
|
|
||||||
+ if (this.dragonFight != null) {
|
|
||||||
gameprofilerfiller.push("dragonFight");
|
|
||||||
this.dragonFight.tick();
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
@@ -898,7 +901,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
if (!entity.isRemoved()) {
|
|
||||||
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
|
||||||
entity.discard();
|
|
||||||
- } else if (!tickratemanager.isEntityFrozen(entity)) {
|
|
||||||
+ } else {
|
|
||||||
gameprofilerfiller.push("checkDespawn");
|
|
||||||
entity.checkDespawn();
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
@@ -1023,20 +1026,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
gameprofilerfiller.popPush("iceandsnow");
|
gameprofilerfiller.popPush("iceandsnow");
|
||||||
|
|
||||||
if (!this.paperConfig().environment.disableIceAndSnow) { // Paper
|
if (!this.paperConfig().environment.disableIceAndSnow) { // Paper
|
||||||
@ -2189,82 +2306,26 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
- // Paper end
|
- // Paper end
|
||||||
+ for (int l = 0; l < randomTickSpeed; ++l) {
|
+ for (int l = 0; l < randomTickSpeed; ++l) {
|
||||||
+ if (this.random.nextInt(48) == 0) {
|
+ if (this.random.nextInt(48) == 0) {
|
||||||
|
+ // Paper start
|
||||||
+ this.getRandomBlockPosition(j, 0, k, 15, blockposition);
|
+ this.getRandomBlockPosition(j, 0, k, 15, blockposition);
|
||||||
+ this.tickIceAndSnow(flag, blockposition, chunk);
|
+ this.tickPrecipitation(blockposition, chunk);
|
||||||
|
+ // Paper end
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
- }
|
- }
|
||||||
} // Paper
|
} // Paper
|
||||||
|
|
||||||
+ // Paper start - optimise random block ticking
|
|
||||||
gameprofilerfiller.popPush("tickBlocks");
|
gameprofilerfiller.popPush("tickBlocks");
|
||||||
timings.chunkTicksBlocks.startTiming(); // Paper
|
@@ -1074,7 +1094,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
if (randomTickSpeed > 0) {
|
|
||||||
- // Paper start - optimize random block ticking
|
|
||||||
LevelChunkSection[] sections = chunk.getSections();
|
|
||||||
final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this);
|
|
||||||
for (int sectionIndex = 0; sectionIndex < sections.length; sectionIndex++) {
|
|
||||||
@@ -1061,9 +1062,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
BlockState iblockdata = com.destroystokyo.paper.util.maplist.IBlockDataList.getBlockDataFromRaw(raw);
|
|
||||||
|
|
||||||
iblockdata.randomTick(this, blockposition2, this.randomTickRandom);
|
@VisibleForTesting
|
||||||
+ // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock).
|
public void tickPrecipitation(BlockPos pos) {
|
||||||
+ // TODO CHECK ON UPDATE (ping the Canadian)
|
|
||||||
}
|
|
||||||
- // We drop the fluid tick since LAVA is ALREADY TICKED by the above method (See LiquidBlock).
|
|
||||||
- // TODO CHECK ON UPDATE (ping the Canadian)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Paper end - optimise random block ticking
|
|
||||||
@@ -1072,24 +1073,20 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
- @VisibleForTesting
|
|
||||||
- public void tickPrecipitation(BlockPos pos) {
|
|
||||||
- // Paper start - optimise chunk ticking
|
- // Paper start - optimise chunk ticking
|
||||||
- tickPrecipitation(pos.mutable(), this.getChunkAt(pos));
|
|
||||||
- }
|
|
||||||
- public void tickPrecipitation(BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) {
|
|
||||||
+ private void tickIceAndSnow(boolean raining, BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) { // Paper - optimise chunk ticking
|
|
||||||
+ // Paper start - optimise chunk ticking
|
+ // Paper start - optimise chunk ticking
|
||||||
int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition1.getX() & 15, blockposition1.getZ() & 15) + 1;
|
tickPrecipitation(pos.mutable(), this.getChunkAt(pos));
|
||||||
int downY = normalY - 1;
|
|
||||||
blockposition1.setY(normalY);
|
|
||||||
- // Paper end - optimise chunk ticking
|
|
||||||
Biome biomebase = (Biome) this.getBiome(blockposition1).value();
|
|
||||||
|
|
||||||
blockposition1.setY(downY);
|
|
||||||
if (biomebase.shouldFreeze(this, blockposition1)) {
|
|
||||||
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
|
|
||||||
}
|
}
|
||||||
+ // Paper end - optimise chunk ticking
|
public void tickPrecipitation(BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) {
|
||||||
|
@@ -1381,9 +1401,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
- if (this.isRaining()) {
|
|
||||||
+ if (raining) {
|
|
||||||
int i = this.getGameRules().getInt(GameRules.RULE_SNOW_ACCUMULATION_HEIGHT);
|
|
||||||
|
|
||||||
blockposition1.setY(normalY); // Paper - optimise chunk ticking
|
|
||||||
@@ -1146,7 +1143,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
return (BlockPos) optional.get();
|
|
||||||
} else {
|
|
||||||
- AABB axisalignedbb = AABB.encapsulatingFullBlocks(blockposition1, new BlockPos(blockposition1.atY(this.getMaxBuildHeight()))).inflate(3.0D);
|
|
||||||
+ AABB axisalignedbb = (new AABB(blockposition1, new BlockPos(blockposition1.getX(), this.getMaxBuildHeight(), blockposition1.getZ()))).inflate(3.0D);
|
|
||||||
List<LivingEntity> list = this.getEntitiesOfClass(LivingEntity.class, axisalignedbb, (entityliving) -> {
|
|
||||||
return entityliving != null && entityliving.isAlive() && this.canSeeSky(entityliving.blockPosition()) && !entityliving.isSpectator(); // Paper - Fix lightning being able to hit spectators (MC-262422)
|
|
||||||
});
|
|
||||||
@@ -1317,8 +1314,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- @VisibleForTesting
|
|
||||||
- public void resetWeatherCycle() {
|
|
||||||
+ private void resetWeatherCycle() {
|
|
||||||
// CraftBukkit start
|
|
||||||
this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
|
|
||||||
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
|
||||||
@@ -1381,9 +1377,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
currentlyTickingEntity.lazySet(entity);
|
currentlyTickingEntity.lazySet(entity);
|
||||||
}
|
}
|
||||||
// Paper end - log detailed entity tick information
|
// Paper end - log detailed entity tick information
|
||||||
@ -2277,7 +2338,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
/*if (!org.spigotmc.ActivationRange.checkIfActive(entity)) { // Paper - comment out - EAR 2, reimplement below
|
/*if (!org.spigotmc.ActivationRange.checkIfActive(entity)) { // Paper - comment out - EAR 2, reimplement below
|
||||||
entity.tickCount++;
|
entity.tickCount++;
|
||||||
timer = entity.getType().inactiveTickTimer.startTiming(); try { // Paper - timings
|
timer = entity.getType().inactiveTickTimer.startTiming(); try { // Paper - timings
|
||||||
@@ -1391,36 +1387,36 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -1391,36 +1411,36 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
} finally { timer.stopTiming(); } // Paper
|
} finally { timer.stopTiming(); } // Paper
|
||||||
return;
|
return;
|
||||||
}*/ // Paper - comment out EAR 2
|
}*/ // Paper - comment out EAR 2
|
||||||
@ -2341,7 +2402,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
} finally {
|
} finally {
|
||||||
if (currentlyTickingEntity.get() == entity) {
|
if (currentlyTickingEntity.get() == entity) {
|
||||||
currentlyTickingEntity.lazySet(null);
|
currentlyTickingEntity.lazySet(null);
|
||||||
@@ -1436,36 +1432,36 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -1436,36 +1456,36 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
|
final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger);
|
||||||
co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper
|
co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper
|
||||||
try {
|
try {
|
||||||
@ -2405,7 +2466,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
passenger.stopRiding();
|
passenger.stopRiding();
|
||||||
@@ -1519,18 +1515,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -1519,18 +1539,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
if (!savingDisabled) {
|
if (!savingDisabled) {
|
||||||
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit
|
org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit
|
||||||
try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
|
try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper
|
||||||
@ -2433,25 +2494,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
timings.worldSaveChunks.stopTiming(); // Paper
|
timings.worldSaveChunks.stopTiming(); // Paper
|
||||||
}// Paper
|
}// Paper
|
||||||
// Paper - rewrite chunk system - entity saving moved into ChunkHolder
|
// Paper - rewrite chunk system - entity saving moved into ChunkHolder
|
||||||
@@ -1810,13 +1806,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
@@ -1858,47 +1878,47 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- public void playSeededSound(@Nullable Player source, double x, double y, double z, Holder<SoundEvent> sound, SoundSource category, float volume, float pitch, long seed) {
|
|
||||||
- this.server.getPlayerList().broadcast(source, x, y, z, (double) ((SoundEvent) sound.value()).getRange(volume), this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch, seed));
|
|
||||||
+ public void playSeededSound(@Nullable Player except, double x, double y, double z, Holder<SoundEvent> sound, SoundSource category, float volume, float pitch, long seed) {
|
|
||||||
+ this.server.getPlayerList().broadcast(except, x, y, z, (double) ((SoundEvent) sound.value()).getRange(volume), this.dimension(), new ClientboundSoundPacket(sound, category, x, y, z, volume, pitch, seed));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- public void playSeededSound(@Nullable Player source, Entity entity, Holder<SoundEvent> sound, SoundSource category, float volume, float pitch, long seed) {
|
|
||||||
- this.server.getPlayerList().broadcast(source, entity.getX(), entity.getY(), entity.getZ(), (double) ((SoundEvent) sound.value()).getRange(volume), this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch, seed));
|
|
||||||
+ public void playSeededSound(@Nullable Player except, Entity entity, Holder<SoundEvent> sound, SoundSource category, float volume, float pitch, long seed) {
|
|
||||||
+ this.server.getPlayerList().broadcast(except, entity.getX(), entity.getY(), entity.getZ(), (double) ((SoundEvent) sound.value()).getRange(volume), this.dimension(), new ClientboundSoundEntityPacket(sound, category, entity, volume, pitch, seed));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@@ -1858,47 +1854,47 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
|
|
||||||
this.getChunkSource().blockChanged(pos);
|
this.getChunkSource().blockChanged(pos);
|
||||||
if(this.paperConfig().misc.updatePathfindingOnBlockUpdate) { // Paper - option to disable pathfinding updates
|
if(this.paperConfig().misc.updatePathfindingOnBlockUpdate) { // Paper - option to disable pathfinding updates
|
||||||
@ -2531,85 +2574,6 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..52986791c160c3454101754253110979
|
|||||||
} // Paper
|
} // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1939,8 +1935,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions particle, ParticleOptions emitterParticle, SoundEvent soundEvent) {
|
|
||||||
- Explosion explosion = this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, false, particle, emitterParticle, soundEvent);
|
|
||||||
+ public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType) {
|
|
||||||
+ Explosion explosion = this.explode(entity, damageSource, behavior, x, y, z, power, createFire, explosionSourceType, false);
|
|
||||||
// CraftBukkit start
|
|
||||||
if (explosion.wasCanceled) {
|
|
||||||
return explosion;
|
|
||||||
@@ -1957,7 +1953,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
|
||||||
|
|
||||||
if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) {
|
|
||||||
- entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound()));
|
|
||||||
+ entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2112,11 +2108,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
return this.server.getRecipeManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
- @Override
|
|
||||||
- public TickRateManager tickRateManager() {
|
|
||||||
- return this.server.tickRateManager();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
@Override
|
|
||||||
public boolean noSave() {
|
|
||||||
return this.noSave;
|
|
||||||
@@ -2142,8 +2133,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
new MapInitializeEvent(map.mapView).callEvent();
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
- } else if (existing instanceof MapItemSavedData mapItemSavedData) {
|
|
||||||
- mapItemSavedData.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return existing instanceof MapItemSavedData data ? data : null;
|
|
||||||
@@ -2152,11 +2141,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMapData(String id, MapItemSavedData state) {
|
|
||||||
- // CraftBukkit start
|
|
||||||
- state.id = id;
|
|
||||||
- MapInitializeEvent event = new MapInitializeEvent(state.mapView);
|
|
||||||
- Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
- // CraftBukkit end
|
|
||||||
+ state.id = id; // CraftBukkit
|
|
||||||
this.getServer().overworld().getDataStorage().set(id, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2719,16 +2704,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
return this.randomSequences;
|
|
||||||
}
|
|
||||||
|
|
||||||
- @Override
|
|
||||||
- public CrashReportCategory fillReportDetails(CrashReport report) {
|
|
||||||
- CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report);
|
|
||||||
-
|
|
||||||
- crashreportsystemdetails.setDetail("Loaded entity count", () -> {
|
|
||||||
- return String.valueOf(this.entityLookup.getAllCopy().length); // Paper
|
|
||||||
- });
|
|
||||||
- return crashreportsystemdetails;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
// Paper start - optimize redstone (Alternate Current)
|
|
||||||
@Override
|
|
||||||
public alternate.current.wire.WireHandler getWireHandler() {
|
|
||||||
@@ -2796,7 +2771,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
|
||||||
- entity.inWorld = true; // CraftBukkit - Mark entity as in world
|
|
||||||
entity.valid = true; // CraftBukkit
|
|
||||||
ServerLevel.this.getChunkSource().addEntity(entity);
|
|
||||||
// Paper start - Set origin location when the entity is being added to the world
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
index 16fbc633de3a1d9e5e8c65ae107397a6f0e50811..d04c0147a87d4b31e6b5b090abeec316d235f1bd 100644
|
index 16fbc633de3a1d9e5e8c65ae107397a6f0e50811..d04c0147a87d4b31e6b5b090abeec316d235f1bd 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||||
|
@ -5,13 +5,13 @@ Subject: [PATCH] Build changes
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..780ef52f50556633c2e402790e339ef513f6bf24 100644
|
index 58da26ad2f128ba0b66f86820f60853f4be352f0..9c2cb599161826748cfcc41362ebdf673b4660e0 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -27,8 +27,13 @@ repositories {
|
@@ -13,8 +13,13 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
||||||
|
val alsoShade: Configuration by configurations.creating
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
extraRuntime(platform("net.kyori:adventure-bom:4.15.0-SNAPSHOT"))
|
|
||||||
- implementation(project(":paper-api"))
|
- implementation(project(":paper-api"))
|
||||||
- implementation(project(":paper-mojangapi"))
|
- implementation(project(":paper-mojangapi"))
|
||||||
+ implementation(project(":aswm-core"))
|
+ implementation(project(":aswm-core"))
|
||||||
@ -24,7 +24,7 @@ index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..780ef52f50556633c2e402790e339ef5
|
|||||||
// Paper start
|
// Paper start
|
||||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||||
@@ -80,11 +85,19 @@ tasks.jar {
|
@@ -66,11 +71,19 @@ tasks.jar {
|
||||||
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
||||||
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
||||||
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
||||||
@ -46,7 +46,7 @@ index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..780ef52f50556633c2e402790e339ef5
|
|||||||
"Implementation-Vendor" to date, // Paper
|
"Implementation-Vendor" to date, // Paper
|
||||||
"Specification-Title" to "Bukkit",
|
"Specification-Title" to "Bukkit",
|
||||||
"Specification-Version" to project.version,
|
"Specification-Version" to project.version,
|
||||||
@@ -168,7 +181,7 @@ fun TaskContainer.registerRunTask(
|
@@ -154,7 +167,7 @@ fun TaskContainer.registerRunTask(
|
||||||
name: String,
|
name: String,
|
||||||
block: JavaExec.() -> Unit
|
block: JavaExec.() -> Unit
|
||||||
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
||||||
|
51
patches/server/0003-UUID-validation.patch
Normal file
51
patches/server/0003-UUID-validation.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 13:11:22 -0600
|
||||||
|
Subject: [PATCH] UUID validation
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
index b65dcff9812dbc3256c080ac264c4aafd83ce276..82b53a7bfb37bfa1752a016a8a454c0b994b9108 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
@@ -74,7 +74,11 @@ public final class NbtUtils {
|
||||||
|
UUID uUID = nbt.hasUUID("Id") ? nbt.getUUID("Id") : Util.NIL_UUID;
|
||||||
|
// Paper start - support string UUID's
|
||||||
|
if (nbt.contains("Id", Tag.TAG_STRING)) {
|
||||||
|
- uUID = UUID.fromString(nbt.getString("Id"));
|
||||||
|
+ // Scissors start - Validate String UUIDs in game profiles
|
||||||
|
+ try {
|
||||||
|
+ uUID = UUID.fromString(nbt.getString("Id"));
|
||||||
|
+ } catch (Exception ignored) {}
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
String string = nbt.getString("Name");
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
index 7fd85ae2ebd7225f06d874aa7e37fbdb89e3ea92..b2cc15da40aa7bbcfc234b4e147ed0e53f359efa 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
@@ -20,6 +20,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.TagParser;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.ExtraCodecs;
|
||||||
|
+import net.minecraft.util.GsonHelper;
|
||||||
|
import net.minecraft.util.StringRepresentable;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
@@ -161,7 +162,14 @@ public class HoverEvent {
|
||||||
|
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||||
|
Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||||
|
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||||
|
- UUID uUID = UUID.fromString(compoundTag.getString("id"));
|
||||||
|
+ // Scissors start
|
||||||
|
+ UUID uUID;
|
||||||
|
+ try {
|
||||||
|
+ uUID = UUID.fromString(compoundTag.getString("id"));
|
||||||
|
+ } catch (Exception ex) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
return DataResult.success(new HoverEvent.EntityTooltipInfo(entityType, uUID, component));
|
||||||
|
} catch (Exception var5) {
|
||||||
|
return DataResult.error(() -> {
|
189
patches/server/0004-ResourceLocation-validation.patch
Normal file
189
patches/server/0004-ResourceLocation-validation.patch
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 13:40:21 -0600
|
||||||
|
Subject: [PATCH] ResourceLocation validation
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||||
|
index 15173e715fa36546820d930a46e0f0c493d07cfc..356cc6f468975faa676db87db8fc0fa2df32f020 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||||
|
@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.loot.LootTable getLootTable() {
|
||||||
|
- return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null;
|
||||||
|
+ return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; // Scissors - Validate length of loot tables before even trying
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
|
index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009b6be7936 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
|
@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.bukkit.loot.LootTable getLootTable() {
|
||||||
|
- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null;
|
||||||
|
+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
|
index 1f55185814125c691288294d18bf1580461c8066..259d65f8e21f9cf99585d416eafdc967dddccf57 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
|
@@ -409,7 +409,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
|
||||||
|
try {
|
||||||
|
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup()));
|
||||||
|
} catch (CommandSyntaxException commandsyntaxexception) {
|
||||||
|
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
|
||||||
|
+ // Scissors - Don't log custom particle errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
|
index 940b8d0b89d7e55c938aefbe80ee71b0db3dacb8..297a214a7833fd67640c94352671483bc4fc8dd5 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
|
@@ -593,7 +593,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||||
|
}), (entity) -> {
|
||||||
|
entity.load(nbt);
|
||||||
|
}, () -> {
|
||||||
|
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
|
||||||
|
+ // Scissors - Don't log invalid entities
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -612,7 +612,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<EntityType<?>> by(CompoundTag nbt) {
|
||||||
|
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
||||||
|
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
index e0cf7771488ab0065708d68b4e8550b865af0ed4..0dbfa66c41ba8242b6389296d175d7d738aac3ca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
@@ -620,7 +620,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
|
|
||||||
|
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
||||||
|
if (nbt.contains("DeathLootTable", 8)) {
|
||||||
|
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
|
||||||
|
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors
|
||||||
|
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 a18aadbf7ae83713e1f2b21553185d8000bc7699..f5ad7ddf13cbb6452c2927aef9b54eae3335b4c6 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
|
||||||
|
@@ -289,7 +289,12 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String s = (String) iterator.next();
|
||||||
|
|
||||||
|
- this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s));
|
||||||
|
+ // Scissors start
|
||||||
|
+ final ResourceLocation rl = ResourceLocation.tryParse(s);
|
||||||
|
+ if (rl != null) {
|
||||||
|
+ this.recipesUsed.put(rl, nbttagcompound1.getInt(s));
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paper start - cook speed API
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||||
|
index b5b1831631e233a96b6fd55972a8862b0f420da8..a086f12c09a5e38f63c8de118fcb5a6a30e40b52 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
||||||
|
@@ -199,7 +199,7 @@ public class BrushableBlockEntity extends BlockEntity {
|
||||||
|
|
||||||
|
private boolean tryLoadLootTable(CompoundTag nbt) {
|
||||||
|
if (nbt.contains("LootTable", 8)) {
|
||||||
|
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
||||||
|
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors
|
||||||
|
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
index 64875525df244db838560f5fefb7b1b07b0f1f51..fd490db7431404b0324e5ade474ec95d694aa489 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||||
|
@@ -50,7 +50,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||||
|
// Copied from super with changes, always check the original method
|
||||||
|
this.lootableData.loadNbt(nbt); // Paper
|
||||||
|
if (nbt.contains("LootTable", 8)) {
|
||||||
|
- this.setLootTable(new ResourceLocation(nbt.getString("LootTable")));
|
||||||
|
+ this.setLootTable(ResourceLocation.tryParse((nbt.getString("LootTable")))); // Scissors - Validate loot tables
|
||||||
|
try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
|
||||||
|
this.setLootTableSeed(nbt.getLong("LootTableSeed"));
|
||||||
|
return false; // Paper - always load the items, table may still remain
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||||
|
index f6942cb3ef1f9ef03708d4bc932ea9aeb1c13894..8b32864bafb3c1948993688be8f639dd6492057e 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||||
|
@@ -34,8 +34,14 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity>
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
- ResourceLocation key = this.getSnapshot().lootTable;
|
||||||
|
- return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
|
||||||
|
+ // Scissors start - Return a null loot table if the specified loot table is not valid
|
||||||
|
+ try {
|
||||||
|
+ ResourceLocation key = this.getSnapshot().lootTable;
|
||||||
|
+ return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key));
|
||||||
|
+ } catch (Exception ex) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
|
||||||
|
index 313ee5c8737b2e57f9b5db6512c1871766b2ccd4..a115a13ec911884a804800fc13f0347be1a30932 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
|
||||||
|
@@ -33,8 +33,15 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
|
||||||
|
return null; // return empty loot table?
|
||||||
|
}
|
||||||
|
|
||||||
|
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
|
||||||
|
- return Bukkit.getLootTable(key);
|
||||||
|
+ // Scissors start - Return a null loot table if the specified loot table is not valid
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(nmsTable);
|
||||||
|
+ return Bukkit.getLootTable(key);
|
||||||
|
+ } catch (Exception exception) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
index 5f6a1fb323782816f706ccf7df922cb203238302..21b4594379a5e904ad60f9c9512ace94e7ed5f68 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
|
@@ -80,8 +80,15 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LootTable getLootTable() {
|
||||||
|
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
|
||||||
|
- return Bukkit.getLootTable(key);
|
||||||
|
+ // Scissors start - Return a null loot table if the specified loot table is not valid
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
|
||||||
|
+ return Bukkit.getLootTable(key);
|
||||||
|
+ } catch (Exception ex) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 16:57:48 -0600
|
||||||
|
Subject: [PATCH] Fixes log spam caused by invalid entities in beehives
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
|
index dfd364ac4b7551a13c4c6c100b5e62c0dfb10595..e0b0dec10dfc5d8e336a4c0f7005e7186f925c1a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
|
@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
@@ -370,6 +371,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||||
|
|
||||||
|
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||||
|
CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
|
||||||
|
+
|
||||||
|
+ // Scissors start - Do not allow invalid entities from being used for bees
|
||||||
|
+ if (!nbttagcompound1.contains("id") || !ResourceLocation.isValidResourceLocation(nbttagcompound1.getString("id")) || EntityType.byString(nbttagcompound1.getString("id")).isEmpty()) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
BeehiveBlockEntity.BeeData tileentitybeehive_hivebee = new BeehiveBlockEntity.BeeData(nbttagcompound1.getCompound("EntityData").copy(), nbttagcompound1.getInt("TicksInHive"), nbttagcompound1.getInt("MinOccupationTicks"));
|
||||||
|
|
||||||
|
this.stored.add(tileentitybeehive_hivebee);
|
@ -0,0 +1,20 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 16:58:55 -0600
|
||||||
|
Subject: [PATCH] Removes useless spammy error logging
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
index 182bc05a839781794188352120968fdf67e794e7..98118cadae93000192003b40e9051a6df216d197 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
@@ -1812,8 +1812,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
|
resource = CraftNamespacedKey.fromMinecraft(key);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
- org.bukkit.Bukkit.getLogger().warning("Namespaced resource does not validate: " + key.toString());
|
||||||
|
- ex.printStackTrace();
|
||||||
|
+ // Scissors - Don't log errors thrown by invalid namespaces when an error is thrown
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource;
|
@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 08:14:44 -0600
|
||||||
|
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities
|
||||||
|
with content in them
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
index 6d23c39e4eadf23616080d6d08672e13b5d3c37d..0bd5c3e3bb7074b5265e3f1bf670f993c9fe167d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
|
@@ -139,7 +139,11 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
|
@Override
|
||||||
|
public void remove(Entity.RemovalReason reason) {
|
||||||
|
if (!this.level().isClientSide && reason.shouldDestroy()) {
|
||||||
|
- Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
||||||
|
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
|
||||||
|
+ try {
|
||||||
|
+ Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
||||||
|
+ } catch (Exception ignored) {}
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
super.remove(reason);
|
@ -0,0 +1,28 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 14:38:38 -0300
|
||||||
|
Subject: [PATCH] ItemEntity - Check if items are air before calling setItem
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
index a39db702063887cf530f272deaf4f334047cc7d4..1816d8bc0716d06cb3db37730234bd37b100f573 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
|
@@ -444,11 +444,15 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||||
|
|
||||||
|
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
||||||
|
|
||||||
|
- this.setItem(ItemStack.of(nbttagcompound1));
|
||||||
|
- if (this.getItem().isEmpty()) {
|
||||||
|
+ // Scissors start
|
||||||
|
+ ItemStack item = ItemStack.of(nbttagcompound1);
|
||||||
|
+ if (item.isEmpty()) {
|
||||||
|
this.discard();
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ this.setItem(item);
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
@ -0,0 +1,49 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 18:42:07 -0600
|
||||||
|
Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is
|
||||||
|
provided
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||||
|
index 37f37be56bab171df442b980ff46ff325daae283..deade19d16a7d6870171b9a60806a8cadb437db4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||||
|
@@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item {
|
||||||
|
|
||||||
|
for(int i = 0; i < listTag.size(); ++i) {
|
||||||
|
String string = listTag.getString(i);
|
||||||
|
- Optional<RecipeHolder<?>> optional = recipeManager.byKey(new ResourceLocation(string));
|
||||||
|
+ Optional<RecipeHolder<?>> optional = recipeManager.byKey(ResourceLocation.tryParse(string)); // Scissors - Validate resource locations
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
- LOGGER.error("Invalid recipe: {}", (Object)string);
|
||||||
|
+ // Scissors - Don't log errors caused by invalid recipes being provided
|
||||||
|
return InteractionResultHolder.fail(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ public class KnowledgeBookItem extends Item {
|
||||||
|
|
||||||
|
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
||||||
|
} else {
|
||||||
|
- LOGGER.error("Tag not valid: {}", (Object)compoundTag);
|
||||||
|
+ // Scissors - Don't throw errors into the logs if an NBT compound isn't present or is missing the Recipes tag.
|
||||||
|
return InteractionResultHolder.fail(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
|
index e904bf8b6a7d18a0e846c3b59e2d7f3d6e530e39..65b076b376bf6ab363a3eb62dfa2c96c45624957 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
|
@@ -41,7 +41,11 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
|
||||||
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
|
String recipe = pages.getString(i);
|
||||||
|
|
||||||
|
- this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
||||||
|
+ // Scissors start - Don't add recipes with invalid namespaces
|
||||||
|
+ try {
|
||||||
|
+ this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
||||||
|
+ } catch (Exception ignored) {}
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 21:56:29 -0600
|
||||||
|
Subject: [PATCH] Validate BlockState and SoundEvent values
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
index 82b53a7bfb37bfa1752a016a8a454c0b994b9108..b8720020f98ea26da7d3225ddfbb1d9e80be4eb1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
@@ -231,7 +231,7 @@ public final class NbtUtils {
|
||||||
|
if (!nbt.contains("Name", 8)) {
|
||||||
|
return Blocks.AIR.defaultBlockState();
|
||||||
|
} else {
|
||||||
|
- ResourceLocation resourceLocation = new ResourceLocation(nbt.getString("Name"));
|
||||||
|
+ ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name")); // Scissors - Validate BlockState
|
||||||
|
Optional<? extends Holder<Block>> optional = blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation));
|
||||||
|
if (optional.isEmpty()) {
|
||||||
|
return Blocks.AIR.defaultBlockState();
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
index 42ebd91196ae420eee57f4380abc558555457163..8e81f50b52bc1d3eb25a842d1c41a7a18f53bf27 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
@@ -560,7 +560,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||||
|
this.setCritArrow(nbt.getBoolean("crit"));
|
||||||
|
this.setPierceLevel(nbt.getByte("PierceLevel"));
|
||||||
|
if (nbt.contains("SoundEvent", 8)) {
|
||||||
|
- this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent());
|
||||||
|
+ this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Scissors - Validate SoundEvents before trying to play them
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow"));
|
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 17:13:15 -0600
|
||||||
|
Subject: [PATCH] Do not log invalid items in HoverEvent and ItemFrame
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
index b2cc15da40aa7bbcfc234b4e147ed0e53f359efa..dbe9f81e298a931c3e0e5b879dc13b493b3fdb52 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
@@ -280,7 +280,7 @@ public class HoverEvent {
|
||||||
|
return DataResult.success(new HoverEvent.ItemStackInfo(ItemStack.of(compoundTag)));
|
||||||
|
} catch (CommandSyntaxException var2) {
|
||||||
|
return DataResult.error(() -> {
|
||||||
|
- return "Failed to parse item tag: " + var2.getMessage();
|
||||||
|
+ return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
|
index 69912c5b300b67394dce3876d2d96872033cf156..ebc403ff31385a12e072fd6a419a7787ee76429e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
|
@@ -436,7 +436,7 @@ public class ItemFrame extends HangingEntity {
|
||||||
|
ItemStack itemstack = ItemStack.of(nbttagcompound1);
|
||||||
|
|
||||||
|
if (itemstack.isEmpty()) {
|
||||||
|
- ItemFrame.LOGGER.warn("Unable to load item from: {}", nbttagcompound1);
|
||||||
|
+ // Scissors - ignore invalid items
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack itemstack1 = this.getItem();
|
91
patches/server/0012-Change-version-fetcher-to-AMG.patch
Normal file
91
patches/server/0012-Change-version-fetcher-to-AMG.patch
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sat, 26 Mar 2022 21:51:07 -0500
|
||||||
|
Subject: [PATCH] Change version fetcher to AMG
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..bc5ed619e05f24f3ad50a6a81306d120869f57a1 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
@@ -4,11 +4,13 @@ import com.destroystokyo.paper.util.VersionFetcher;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.io.Resources;
|
||||||
|
import com.google.gson.*;
|
||||||
|
+import io.papermc.paper.util.JarManifests; // Scissors
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
+import org.bukkit.Bukkit; // Scissors
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
|
public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||||
|
- private static final String GITHUB_BRANCH_NAME = "master";
|
||||||
|
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper";
|
||||||
|
+ private static final String GITHUB_BRANCH_NAME = getBranch(); // Scissors
|
||||||
|
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME; // Scissors
|
||||||
|
private static @Nullable String mcVer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||||
|
- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
|
||||||
|
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
|
||||||
|
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]"); // Scissors
|
||||||
|
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]); // Scissors
|
||||||
|
final Component history = getHistory();
|
||||||
|
|
||||||
|
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||||
|
@@ -54,15 +56,24 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
return mcVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start - Allow getting git information
|
||||||
|
+ public static String getCommit() {
|
||||||
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||||
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static String getBranch() {
|
||||||
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||||
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||||
|
int distance;
|
||||||
|
- try {
|
||||||
|
- int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||||
|
- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||||
|
- } catch (NumberFormatException ignored) {
|
||||||
|
- versionInfo = versionInfo.replace("\"", "");
|
||||||
|
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||||
|
- }
|
||||||
|
+ // Scissors start - always use Git for version checking
|
||||||
|
+ versionInfo = getCommit();
|
||||||
|
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||||
|
+ // Scissors end
|
||||||
|
|
||||||
|
switch (distance) {
|
||||||
|
case -1:
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
index a74a8a027c99eef199c1a6a54232ac2c8ffb9d08..1576a201c92d8b17fd3a92ec497c42861db8ad1e 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -301,7 +301,7 @@ public class Main {
|
||||||
|
if (buildDate.before(deadline.getTime())) {
|
||||||
|
// Paper start - This is some stupid bullshit
|
||||||
|
System.err.println("*** Warning, you've not updated in a while! ***");
|
||||||
|
- System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads/paper ***"); // Paper
|
||||||
|
+ System.err.println("*** Please download a new build from https://ci.scissors.gg/job/Scissors ***"); // Scissors > // Paper
|
||||||
|
//System.err.println("*** Server will start in 20 seconds ***");
|
||||||
|
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
||||||
|
// Paper End
|
@ -0,0 +1,150 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 17:26:11 -0600
|
||||||
|
Subject: [PATCH] Better handling of invalid JSON components
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
index 200ed770b57e1a9240abf0473968d4b85cbefe3c..1a2a3b506e2f9bce77294c3788451bfd47394548 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
|
@@ -654,12 +654,6 @@ public final class MCUtil {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String string = compound.getString(key);
|
||||||
|
- try {
|
||||||
|
- return net.minecraft.network.chat.Component.Serializer.fromJson(string);
|
||||||
|
- } catch (com.google.gson.JsonParseException e) {
|
||||||
|
- org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return null;
|
||||||
|
+ return net.minecraft.network.chat.Component.Serializer.fromJsonSafe(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
|
index d3a80d0a23be762c05931ae8001d98e43cab2b4a..ba13650b52e39c9cc5cfa421f7720c7d4ba75678 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
|
@@ -23,6 +23,8 @@ import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.network.chat.contents.DataSource;
|
||||||
|
import net.minecraft.network.chat.contents.KeybindContents;
|
||||||
|
@@ -315,6 +317,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||||
|
return json == null ? null : Serializer.deserialize(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // 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
|
||||||
|
+
|
||||||
|
@Nullable
|
||||||
|
public static MutableComponent fromJsonLenient(String json) {
|
||||||
|
JsonReader jsonreader = new JsonReader(new StringReader(json));
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
index dbe9f81e298a931c3e0e5b879dc13b493b3fdb52..6708290b6d096e8081c56d2e0da3c9ae2a112176 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
|
@@ -160,7 +160,7 @@ public class HoverEvent {
|
||||||
|
public static DataResult<HoverEvent.EntityTooltipInfo> legacyCreate(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 186547674894fd084bceb478bb6017b747df4173..74c880425964da042ca57c097eb93273da59ce7e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||||
|
@@ -115,10 +115,10 @@ 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);
|
||||||
|
return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth));
|
||||||
|
} catch (Exception var5) {
|
||||||
|
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||||
|
+ // Scissors - don't log
|
||||||
|
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 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..a8ae232f9ef204e6dd2f14c1e92008ceb7af7ab2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -2522,11 +2522,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||||
|
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/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
|
index b49d60d20d170d16a7daf2bc874e5d8d04552b3e..56ae1fa22bb722f91a06d7344bf879210f4ef8f2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
|
@@ -41,7 +41,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);
|
||||||
|
}
|
||||||
|
@@ -59,14 +59,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);
|
||||||
|
}
|
||||||
|
@@ -126,7 +126,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||||
|
return ObjectiveCriteria.DUMMY;
|
||||||
|
});
|
||||||
|
String string2 = 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"));
|
||||||
|
boolean bl = compoundTag.getBoolean("display_auto_update");
|
||||||
|
NumberFormat numberFormat = NumberFormatTypes.CODEC.parse(NbtOps.INSTANCE, compoundTag.get("format")).result().orElse((NumberFormat)null);
|
180
patches/server/0014-Block-server-side-chunkbans.patch
Normal file
180
patches/server/0014-Block-server-side-chunkbans.patch
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ayunami2000 <spwilliamsiam@gmail.com>
|
||||||
|
Date: Mon, 28 Mar 2022 17:02:21 -0400
|
||||||
|
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 d364bd57b1675c8b21d781c2bc16c3e65800455c..f2e7585630ff724f966c7bcedc17e502d786870d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||||
|
@@ -7,8 +7,16 @@ import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
|
import io.netty.util.Attribute;
|
||||||
|
import io.netty.util.AttributeKey;
|
||||||
|
import java.io.IOException;
|
||||||
|
+import java.util.Collections; // Scissors
|
||||||
|
+import net.minecraft.ChatFormatting; // Scissors
|
||||||
|
+import net.minecraft.core.NonNullList; // Scissors
|
||||||
|
+import net.minecraft.nbt.CompoundTag; // Scissors
|
||||||
|
+import net.minecraft.network.chat.Component; // Scissors
|
||||||
|
+import net.minecraft.network.chat.SignedMessageBody; // Scissors
|
||||||
|
import net.minecraft.network.protocol.Packet;
|
||||||
|
+import net.minecraft.network.protocol.game.*; // Scissors
|
||||||
|
import net.minecraft.util.profiling.jfr.JvmProfiler;
|
||||||
|
+import net.minecraft.world.item.ItemStack; // Scissors
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||||
|
@@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||||
|
this.codecKey = protocolKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start
|
||||||
|
+ private int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) {
|
||||||
|
+ friendlyByteBuf.writeVarInt(i);
|
||||||
|
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
||||||
|
+
|
||||||
|
+ int j = friendlyByteBuf.writerIndex();
|
||||||
|
+ packet.write(friendlyByteBuf);
|
||||||
|
+ int k = friendlyByteBuf.writerIndex() - j;
|
||||||
|
+ int packetLength = friendlyByteBuf.readableBytes();
|
||||||
|
+ if (packetLength > MAX_PACKET_SIZE) {
|
||||||
|
+ throw new PacketTooLargeException(packet, this.codecKey, packetLength);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return k;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
|
||||||
|
Attribute<ConnectionProtocol.CodecData<?>> attribute = channelHandlerContext.channel().attr(this.codecKey);
|
||||||
|
ConnectionProtocol.CodecData<?> codecData = attribute.get();
|
||||||
|
@@ -34,46 +59,59 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||||
|
throw new IOException("Can't serialize unregistered packet");
|
||||||
|
} else {
|
||||||
|
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
|
||||||
|
- friendlyByteBuf.writeVarInt(i);
|
||||||
|
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(io.papermc.paper.adventure.PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
||||||
|
|
||||||
|
+ // Scissors start
|
||||||
|
+ int k;
|
||||||
|
try {
|
||||||
|
- int j = friendlyByteBuf.writerIndex();
|
||||||
|
- packet.write(friendlyByteBuf);
|
||||||
|
- int k = friendlyByteBuf.writerIndex() - j;
|
||||||
|
- if (false && k > 8388608) { // Paper - disable
|
||||||
|
- throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k);
|
||||||
|
+ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
|
||||||
|
} catch (Throwable var13) {
|
||||||
|
- // Paper start - Give proper error message
|
||||||
|
- String packetName = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(packet.getClass().getName());
|
||||||
|
- if (packetName.contains(".")) {
|
||||||
|
- packetName = packetName.substring(packetName.lastIndexOf(".") + 1);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- LOGGER.error("Packet encoding of packet {} (ID: {}) threw (skippable? {})", packetName, i, packet.isSkippable(), var13);
|
||||||
|
- // Paper end
|
||||||
|
- if (packet.isSkippable()) {
|
||||||
|
- throw new SkipPacketException(var13);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- throw var13;
|
||||||
|
- } finally {
|
||||||
|
- // Paper start
|
||||||
|
- int packetLength = friendlyByteBuf.readableBytes();
|
||||||
|
- if (packetLength > MAX_PACKET_SIZE) {
|
||||||
|
- throw new PacketTooLargeException(packet, this.codecKey, packetLength);
|
||||||
|
+ packet = capPacket(packet, i);
|
||||||
|
+ if (packet == null) {
|
||||||
|
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
|
||||||
|
}
|
||||||
|
- // Paper end
|
||||||
|
- ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
|
||||||
|
+ friendlyByteBuf.clear();
|
||||||
|
+ k = this.tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ JvmProfiler.INSTANCE.onPacketSent(codecData.protocol(), i, channelHandlerContext.channel().remoteAddress(), k);
|
||||||
|
+ ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet);
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start
|
||||||
|
+ private static Packet capPacket(Packet packet, int i) {
|
||||||
|
+ 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 ClientboundContainerSetContentPacket containerSetContentPacket) {
|
||||||
|
+ packet = new ClientboundContainerSetContentPacket(containerSetContentPacket.getContainerId(), containerSetContentPacket.getStateId(), NonNullList.create(), ItemStack.EMPTY);
|
||||||
|
+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) {
|
||||||
|
+ packet = new ClientboundSetEquipmentPacket(setEquipmentPacket.getEntity(), Collections.emptyList());
|
||||||
|
+ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) {
|
||||||
|
+ packet = new ClientboundContainerSetSlotPacket(containerSetSlotPacket.getContainerId(), containerSetSlotPacket.getStateId(), containerSetSlotPacket.getSlot(), ItemStack.EMPTY);
|
||||||
|
+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) {
|
||||||
|
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null);
|
||||||
|
+ } else if (packet instanceof ClientboundPlayerChatPacket playerChatPacket) {
|
||||||
|
+ final SignedMessageBody.Packed body = playerChatPacket.body();
|
||||||
|
+ packet = new ClientboundPlayerChatPacket(playerChatPacket.sender(), // Not sending this packet results in a kick when someone says something.
|
||||||
|
+ playerChatPacket.index(),
|
||||||
|
+ playerChatPacket.signature(),
|
||||||
|
+ playerChatPacket.body(),
|
||||||
|
+ Component.empty().append("** Message too large **").withStyle(ChatFormatting.RED),
|
||||||
|
+ playerChatPacket.filterMask(),
|
||||||
|
+ playerChatPacket.chatType()
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return packet;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
// Paper start
|
||||||
|
private static int MAX_PACKET_SIZE = 8388608;
|
||||||
|
|
||||||
|
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..96ee53c7cc862e059328c5cdf5e07f309df6a79e 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,7 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
|
||||||
|
return create(blockEntity, BlockEntity::getUpdateTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
- private ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) {
|
||||||
|
+ public ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) { // Scissors - private -> public
|
||||||
|
this.pos = pos;
|
||||||
|
this.type = blockEntityType;
|
||||||
|
this.tag = nbt.isEmpty() ? null : nbt;
|
||||||
|
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 51e24105facfe71ce9f2757c6c881a21b58dacfd..5692fbae221fb01d32d92edc7bea0f6312e24e1c 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,13 @@ 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) {
|
||||||
|
@@ -58,6 +65,7 @@ public class ClientboundLevelChunkPacketData {
|
||||||
|
int totalTileEntities = 0; // Paper
|
||||||
|
|
||||||
|
for(Map.Entry<BlockPos, BlockEntity> entry2 : chunk.getBlockEntities().entrySet()) {
|
||||||
|
+ if (this.extraPackets.size() > 50) break; // Scissors - Limit extraPackets size
|
||||||
|
// Paper start
|
||||||
|
if (++totalTileEntities > TE_LIMIT) {
|
||||||
|
var packet = entry2.getValue().getUpdatePacket();
|
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Mon, 28 Mar 2022 16:49:17 -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 7daca712816a79cc4a30b084afbd3d07b5d3755f..a7e04eb4284e7d5148e1c7b991620d666785ec70 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||||
|
@@ -38,8 +38,9 @@ public class ComponentUtils {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||||
|
+ MutableComponent result; // Scissors
|
||||||
|
if (depth > 100) {
|
||||||
|
- return text.copy();
|
||||||
|
+ result = text.copy(); // Scissors
|
||||||
|
} else {
|
||||||
|
// Paper start
|
||||||
|
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
||||||
|
@@ -52,8 +53,9 @@ 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)); // Scissors
|
||||||
|
}
|
||||||
|
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; // Scissors
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
@ -0,0 +1,508 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Sun, 10 Jul 2022 10:12:04 +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 a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb190a622d 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;
|
||||||
|
@@ -242,7 +243,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..8cd2848aa6b06c5efbe797ed2d75ff4b025b3c52
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
||||||
|
@@ -0,0 +1,225 @@
|
||||||
|
+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://javadoc.scissors.gg/1.20.1/\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", 5);
|
||||||
|
+ set("config-version", 5);
|
||||||
|
+ 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);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // people still may want them to bypass permissions for warps
|
||||||
|
+ public static boolean commandSignsBypassPermissions = false;
|
||||||
|
+ private static void commandSignsBypassPermissions()
|
||||||
|
+ {
|
||||||
|
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean chatSignaturesEnabled = true;
|
||||||
|
+ private static void chatSignaturesEnabled()
|
||||||
|
+ {
|
||||||
|
+ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean excludePlayersFromNbtComponents = false;
|
||||||
|
+ private static void excludePlayersFromNbtComponents()
|
||||||
|
+ {
|
||||||
|
+ excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false);
|
||||||
|
+ }
|
||||||
|
+ public static int componentDepthLimit = 128;
|
||||||
|
+ private static void componentDepthLimit()
|
||||||
|
+ {
|
||||||
|
+ componentDepthLimit = getInt("componentDepthLimit", 128);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ 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 7573c12a77797146c51ef2dfe4b2a636df45e21a..90d9c9cbf730df6ec1800a611fd9103418cce607 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Main.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||||
|
@@ -141,6 +141,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
|
||||||
|
|
||||||
|
if (optionset.has("initSettings")) { // CraftBukkit
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
index 58536aabf607015939a1326f80207c0a06eed8ff..34a8c36d88eb17b7574b6766f5e14ef926ec9080 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
@@ -222,6 +222,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
|
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 142d2c48239d4ebe3896218536656d116cd24d7c..36fe3df8b26136a62381336c83fe266a5bf2266d 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -1036,6 +1036,7 @@ public final class CraftServer implements Server {
|
||||||
|
}
|
||||||
|
|
||||||
|
org.spigotmc.SpigotConfig.init((File) this.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
|
||||||
|
@@ -1067,6 +1068,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");
|
||||||
|
|
||||||
|
@@ -3011,6 +3013,14 @@ public final class CraftServer implements Server {
|
||||||
|
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start
|
||||||
|
+ @Override
|
||||||
|
+ public YamlConfiguration getScissorsConfig()
|
||||||
|
+ {
|
||||||
|
+ return me.totalfreedom.scissors.ScissorsConfig.config;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
@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 1576a201c92d8b17fd3a92ec497c42861db8ad1e..81454e29639f428e3331c5c20bb7ad39351d2f8a 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -181,6 +181,20 @@ 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");
|
||||||
|
+
|
||||||
|
+ acceptsAll(asList("scissors", "scissors-settings"), "File for Scissors settings")
|
||||||
|
+ .withRequiredArg()
|
||||||
|
+ .ofType(File.class)
|
||||||
|
+ .defaultsTo(new File("scissors.yml"))
|
||||||
|
+ .describedAs("YAML file");
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,28 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Wed, 30 Mar 2022 18:20:09 -0600
|
||||||
|
Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
|
||||||
|
to CraftMetaItems
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
index 98118cadae93000192003b40e9051a6df216d197..36cd18534910efd410efd9dcc7e4bec27eb99a8f 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
|
@@ -47,6 +47,7 @@ import net.minecraft.nbt.NbtIo;
|
||||||
|
import net.minecraft.nbt.StringTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
+import net.minecraft.resources.ResourceLocation; // Scissors
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
@@ -487,7 +488,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
|
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||||
|
|
||||||
|
String attributeName = org.bukkit.craftbukkit.attribute.CraftAttributeMap.convertIfNeeded(entry.getString(CraftMetaItem.ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
||||||
|
- if (attributeName == null || attributeName.isEmpty()) {
|
||||||
|
+ if (attributeName == null || attributeName.isEmpty() || attributeName.length() > 256 || !ResourceLocation.isValidResourceLocation(attributeName)) { // Scissors
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 17:39:52 -0600
|
||||||
|
Subject: [PATCH] Don't query player data in the `nbt` component
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||||
|
index 3bec895fecb3521653fb0b88d4a4854fd3766b46..5fd278ac13c02b9d511be22dba9719cb0cb0e17b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
||||||
|
@@ -8,12 +8,15 @@ import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||||
|
import net.minecraft.advancements.critereon.NbtPredicate;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||||
|
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
+import net.minecraft.world.entity.player.Player;
|
||||||
|
|
||||||
|
public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource {
|
||||||
|
public static final MapCodec<EntityDataSource> SUB_CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||||
|
@@ -39,7 +42,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
|
||||||
|
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
||||||
|
if (this.compiledSelector != null) {
|
||||||
|
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
||||||
|
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
|
||||||
|
+ // Scissors start
|
||||||
|
+ Stream<? extends Entity> stream = list.stream();
|
||||||
|
+ if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player));
|
||||||
|
+ return stream.map(NbtPredicate::getEntityTagToCompare);
|
||||||
|
+ // Scissors end
|
||||||
|
} else {
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
@ -0,0 +1,142 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Fri, 8 Apr 2022 23:38:12 -0300
|
||||||
|
Subject: [PATCH] Limit string tag visitors to 1024 elements
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||||
|
index e07cc7970955ce240754cfe424d768c2bba0241a..a4f41bb4ec6cb20f782668c714229b61415cfdfb 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
|
||||||
|
@@ -89,6 +89,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||||
|
public void visitByteArray(ByteArrayTag element) {
|
||||||
|
StringBuilder stringBuilder = (new StringBuilder("[")).append("B").append(";");
|
||||||
|
byte[] bs = element.getAsByteArray();
|
||||||
|
+ if (bs.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < bs.length; ++i) {
|
||||||
|
stringBuilder.append(" ").append((int)bs[i]).append("B");
|
||||||
|
@@ -105,6 +106,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||||
|
public void visitIntArray(IntArrayTag element) {
|
||||||
|
StringBuilder stringBuilder = (new StringBuilder("[")).append("I").append(";");
|
||||||
|
int[] is = element.getAsIntArray();
|
||||||
|
+ if (is.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < is.length; ++i) {
|
||||||
|
stringBuilder.append(" ").append(is[i]);
|
||||||
|
@@ -122,6 +124,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||||
|
String string = "L";
|
||||||
|
StringBuilder stringBuilder = (new StringBuilder("[")).append("L").append(";");
|
||||||
|
long[] ls = element.getAsLongArray();
|
||||||
|
+ if (ls.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < ls.length; ++i) {
|
||||||
|
stringBuilder.append(" ").append(ls[i]).append("L");
|
||||||
|
@@ -136,7 +139,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitList(ListTag element) {
|
||||||
|
- if (element.isEmpty()) {
|
||||||
|
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
|
||||||
|
this.result = "[]";
|
||||||
|
} else {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder("[");
|
||||||
|
@@ -166,7 +169,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitCompound(CompoundTag compound) {
|
||||||
|
- if (compound.isEmpty()) {
|
||||||
|
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
|
||||||
|
this.result = "{}";
|
||||||
|
} else {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder("{");
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/StringTagVisitor.java b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||||
|
index a687a0f17df30126d53a1e3a669dc6d157c23ed5..2c50f41dd8034af16fcceca75eeb6c7a9940e327 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
|
||||||
|
@@ -53,6 +53,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||||
|
public void visitByteArray(ByteArrayTag element) {
|
||||||
|
this.builder.append("[B;");
|
||||||
|
byte[] bs = element.getAsByteArray();
|
||||||
|
+ if (bs.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < bs.length; ++i) {
|
||||||
|
if (i != 0) {
|
||||||
|
@@ -69,6 +70,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||||
|
public void visitIntArray(IntArrayTag element) {
|
||||||
|
this.builder.append("[I;");
|
||||||
|
int[] is = element.getAsIntArray();
|
||||||
|
+ if (is.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < is.length; ++i) {
|
||||||
|
if (i != 0) {
|
||||||
|
@@ -85,6 +87,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||||
|
public void visitLongArray(LongArrayTag element) {
|
||||||
|
this.builder.append("[L;");
|
||||||
|
long[] ls = element.getAsLongArray();
|
||||||
|
+ if (ls.length > 1024) { this.builder.append(']'); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < ls.length; ++i) {
|
||||||
|
if (i != 0) {
|
||||||
|
@@ -100,6 +103,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||||
|
@Override
|
||||||
|
public void visitList(ListTag element) {
|
||||||
|
this.builder.append('[');
|
||||||
|
+ if (element.size() > 1024) { this.builder.append(']'); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < element.size(); ++i) {
|
||||||
|
if (i != 0) {
|
||||||
|
@@ -116,6 +120,7 @@ public class StringTagVisitor implements TagVisitor {
|
||||||
|
public void visitCompound(CompoundTag compound) {
|
||||||
|
this.builder.append('{');
|
||||||
|
List<String> list = Lists.newArrayList(compound.getAllKeys());
|
||||||
|
+ if (list.size() > 1024) { this.builder.append('}'); return; } // Scissors
|
||||||
|
Collections.sort(list);
|
||||||
|
|
||||||
|
for(String string : list) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||||
|
index 149def3da0b92f64e4fc04630965dce44884f938..c9d753f37bd65e35f8a4e2eb5c6fe8f74d5d1606 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
|
||||||
|
@@ -97,6 +97,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||||
|
Component component = Component.literal("B").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||||
|
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||||
|
byte[] bs = element.getAsByteArray();
|
||||||
|
+ if (bs.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < bs.length; ++i) {
|
||||||
|
MutableComponent mutableComponent2 = Component.literal(String.valueOf((int)bs[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
|
||||||
|
@@ -115,6 +116,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||||
|
Component component = Component.literal("I").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||||
|
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||||
|
int[] is = element.getAsIntArray();
|
||||||
|
+ if (is.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < is.length; ++i) {
|
||||||
|
mutableComponent.append(" ").append(Component.literal(String.valueOf(is[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER));
|
||||||
|
@@ -132,6 +134,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||||
|
Component component = Component.literal("L").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
|
||||||
|
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
|
||||||
|
long[] ls = element.getAsLongArray();
|
||||||
|
+ if (ls.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
|
||||||
|
|
||||||
|
for(int i = 0; i < ls.length; ++i) {
|
||||||
|
Component component2 = Component.literal(String.valueOf(ls[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
|
||||||
|
@@ -147,7 +150,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitList(ListTag element) {
|
||||||
|
- if (element.isEmpty()) {
|
||||||
|
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
|
||||||
|
this.result = Component.literal("[]");
|
||||||
|
} else if (INLINE_ELEMENT_TYPES.contains(element.getElementType()) && element.size() <= 8) {
|
||||||
|
String string = ELEMENT_SEPARATOR + " ";
|
||||||
|
@@ -190,7 +193,7 @@ public class TextComponentTagVisitor implements TagVisitor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitCompound(CompoundTag compound) {
|
||||||
|
- if (compound.isEmpty()) {
|
||||||
|
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
|
||||||
|
this.result = Component.literal("{}");
|
||||||
|
} else {
|
||||||
|
MutableComponent mutableComponent = Component.literal("{");
|
@ -0,0 +1,34 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Mon, 11 Apr 2022 13:33:52 -0600
|
||||||
|
Subject: [PATCH] Fixes creative-killing potion effects and certain potion
|
||||||
|
effect overflows
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||||
|
index 1c7794de5f0a7238b944c9473e2cc9d011ef2306..9c594c504611b9da5fcd119284b2dcb4b59d3bf4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||||
|
@@ -16,6 +16,11 @@ class HealOrHarmMobEffect extends InstantenousMobEffect {
|
||||||
|
@Override
|
||||||
|
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
|
super.applyEffectTick(entity, amplifier);
|
||||||
|
+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't.
|
||||||
|
+ if (entity instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return;
|
||||||
|
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
if (this.isHarm == entity.isInvertedHealAndHarm()) {
|
||||||
|
entity.heal((float) Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
||||||
|
} else {
|
||||||
|
@@ -27,6 +32,10 @@ class HealOrHarmMobEffect extends InstantenousMobEffect {
|
||||||
|
@Override
|
||||||
|
public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||||
|
int j;
|
||||||
|
+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't.
|
||||||
|
+ if (target instanceof net.minecraft.world.entity.player.Player player && (player.isCreative() || player.isInvulnerable())) return;
|
||||||
|
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||||
|
+ // Scissors end
|
||||||
|
|
||||||
|
if (this.isHarm == target.isInvertedHealAndHarm()) {
|
||||||
|
j = (int) (proximity * (double) (4 << amplifier) + 0.5D);
|
19
patches/server/0021-Fix-negative-death-times.patch
Normal file
19
patches/server/0021-Fix-negative-death-times.patch
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Mon, 18 Apr 2022 16:55:19 +0100
|
||||||
|
Subject: [PATCH] Fix negative death times
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
index bc908b75cb99536df658281ae7f8b4eeedbbedc9..8c81cd6a6563e4eb46a26c30baa3dfd9df3ecf1f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -628,7 +628,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
|
||||||
|
protected void tickDeath() {
|
||||||
|
++this.deathTime;
|
||||||
|
- if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
||||||
|
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) { // Scissors
|
||||||
|
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||||
|
this.remove(Entity.RemovalReason.KILLED);
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Thu, 21 Apr 2022 13:52:32 +0100
|
||||||
|
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 c906ca07509939a06b9aaf2da0dafb172830a638..c1e91ea440202014419aa9601915f9288a41e32c 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; // Scissors
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.BlockUtil;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
@@ -104,6 +105,7 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||||
|
private double flyingX = 0.95;
|
||||||
|
private double flyingY = 0.95;
|
||||||
|
private double flyingZ = 0.95;
|
||||||
|
+ private long lastLargeCollision = 0L; // Scissors - Add a collision debounce
|
||||||
|
public double maxSpeed = 0.4D;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
|
@@ -384,8 +386,8 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||||
|
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()) {
|
||||||
|
- Iterator iterator = list.iterator();
|
||||||
|
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
|
||||||
|
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Entity entity = (Entity) iterator.next();
|
||||||
|
@@ -414,6 +416,14 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||||
|
entity.push(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Scissors start - Add a collision debounce
|
||||||
|
+ if (list.size() > 15) {
|
||||||
|
+ this.discard();
|
||||||
|
+ } else if (list.size() > 3) {
|
||||||
|
+ lastLargeCollision = System.currentTimeMillis();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Iterator iterator1 = 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 c041c0b81be41cfd128c2f5ba56a5329d50b2efc..7dcbdcb30d264cf76fd975489918509e6e589127 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; // Scissors
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.BlockUtil;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
@@ -108,6 +109,7 @@ public class Boat extends VehicleEntity 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);
|
||||||
|
@@ -408,9 +410,9 @@ public class Boat extends VehicleEntity 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()) {
|
||||||
|
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
|
||||||
|
boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player);
|
||||||
|
- Iterator iterator = list.iterator();
|
||||||
|
+ Iterator iterator = list.size() <= 15 ? list.iterator() : list.subList(0, 15).iterator(); // Scissors
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
Entity entity = (Entity) iterator.next();
|
||||||
|
@@ -423,6 +425,14 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Scissors start - Add collision debounce
|
||||||
|
+ if (list.size() > 15) {
|
||||||
|
+ this.discard();
|
||||||
|
+ } else if (list.size() > 3) {
|
||||||
|
+ lastLargeCollision = System.currentTimeMillis();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
181
patches/server/0023-Add-custom-classes-used-by-Scissors.patch
Normal file
181
patches/server/0023-Add-custom-classes-used-by-Scissors.patch
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sat, 11 Jun 2022 22:56:59 -0500
|
||||||
|
Subject: [PATCH] Add custom classes used by Scissors
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/me/totalfreedom/scissors/MathUtility.java b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..754b578b575137a9c48cb20dee965a9388fedb3c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
||||||
|
@@ -0,0 +1,29 @@
|
||||||
|
+package me.totalfreedom.scissors;
|
||||||
|
+
|
||||||
|
+public class MathUtility
|
||||||
|
+{
|
||||||
|
+ public static int clampInt(int number, int minimum, int maximum)
|
||||||
|
+ {
|
||||||
|
+ return Math.min(Math.max(number, minimum), maximum);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static long clampLong(long number, long minimum, long maximum)
|
||||||
|
+ {
|
||||||
|
+ return Math.min(Math.max(number, minimum), maximum);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static double clampDouble(double number, double minimum, double maximum)
|
||||||
|
+ {
|
||||||
|
+ return Math.min(Math.max(number, minimum), maximum);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int safeDoubleToInt(double number)
|
||||||
|
+ {
|
||||||
|
+ return (int) clampDouble(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static int safeLongToInt(long number)
|
||||||
|
+ {
|
||||||
|
+ return (int) clampLong(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/me/totalfreedom/scissors/NbtUtility.java b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..b3efac47ee700d5a7ff26452d6bcbf2f687a32cf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||||
|
@@ -0,0 +1,75 @@
|
||||||
|
+package me.totalfreedom.scissors;
|
||||||
|
+
|
||||||
|
+import java.nio.charset.StandardCharsets;
|
||||||
|
+import javax.annotation.Nullable;
|
||||||
|
+import net.minecraft.nbt.CompoundTag;
|
||||||
|
+import net.minecraft.nbt.ListTag;
|
||||||
|
+import net.minecraft.nbt.Tag;
|
||||||
|
+
|
||||||
|
+public class NbtUtility
|
||||||
|
+{
|
||||||
|
+ public static final long MAXIMUM_SIZE = (256 * 1024);
|
||||||
|
+
|
||||||
|
+ public static long getTagSize(@Nullable Tag tag, int depth)
|
||||||
|
+ {
|
||||||
|
+ if (depth > 512)
|
||||||
|
+ {
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ if (tag == null)
|
||||||
|
+ {
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ long size = 0;
|
||||||
|
+
|
||||||
|
+ if (tag.getType() == CompoundTag.TYPE)
|
||||||
|
+ {
|
||||||
|
+ CompoundTag compoundTag = (CompoundTag) tag;
|
||||||
|
+ for (String key : compoundTag.getAllKeys())
|
||||||
|
+ {
|
||||||
|
+ size += key.getBytes(StandardCharsets.UTF_8).length;
|
||||||
|
+ size += getTagSize(compoundTag.get(key), depth + 1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ else if (tag.getType() == ListTag.TYPE)
|
||||||
|
+ {
|
||||||
|
+ ListTag listTag = (ListTag) tag;
|
||||||
|
+ for (Tag tag1 : listTag)
|
||||||
|
+ {
|
||||||
|
+ size += getTagSize(tag1, depth + 1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return size;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static long getTagSize(@Nullable CompoundTag tag)
|
||||||
|
+ {
|
||||||
|
+ return getTagSize(tag, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||||
|
+ {
|
||||||
|
+ if (tag == null)
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ return getTagSize(tag) > MAXIMUM_SIZE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class Item
|
||||||
|
+ {
|
||||||
|
+ public static CompoundTag removeItemData(CompoundTag tag)
|
||||||
|
+ {
|
||||||
|
+ CompoundTag cleaned = new CompoundTag();
|
||||||
|
+ cleaned.putString("id", tag.getString("id"));
|
||||||
|
+ cleaned.putByte("Count", tag.getByte("Count"));
|
||||||
|
+ return cleaned;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..c5dcc833d6f2c0daa1d0c2a7ab81430f25e0b2f3
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
||||||
|
@@ -0,0 +1,53 @@
|
||||||
|
+package me.totalfreedom.scissors;
|
||||||
|
+
|
||||||
|
+import net.minecraft.core.BlockPos;
|
||||||
|
+import net.minecraft.world.entity.Entity;
|
||||||
|
+import net.minecraft.world.level.Level;
|
||||||
|
+import net.minecraft.world.level.border.WorldBorder;
|
||||||
|
+import net.minecraft.world.phys.Vec3;
|
||||||
|
+
|
||||||
|
+public class PositionUtility
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity)
|
||||||
|
+ {
|
||||||
|
+ final BlockPos validBlockPos = getValidBlockPos(blockPos, entity);
|
||||||
|
+
|
||||||
|
+ return new Vec3(validBlockPos.getX(), validBlockPos.getY(), validBlockPos.getZ());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static BlockPos getValidBlockPos(BlockPos blockPos, Entity entity)
|
||||||
|
+ {
|
||||||
|
+ final Level level = entity.level();
|
||||||
|
+
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ if (level.isInWorldBounds(blockPos))
|
||||||
|
+ {
|
||||||
|
+ return blockPos;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ final int x = blockPos.getX();
|
||||||
|
+ final int y = blockPos.getY();
|
||||||
|
+ final int z = blockPos.getZ();
|
||||||
|
+
|
||||||
|
+ final WorldBorder worldBorder = level.getWorldBorder();
|
||||||
|
+
|
||||||
|
+ final int maxX = MathUtility.safeDoubleToInt(worldBorder.getMaxX());
|
||||||
|
+ final int maxY = level.getMaxBuildHeight();
|
||||||
|
+ final int maxZ = MathUtility.safeDoubleToInt(worldBorder.getMaxZ());
|
||||||
|
+
|
||||||
|
+ final int minX = MathUtility.safeDoubleToInt(worldBorder.getMinX());
|
||||||
|
+ final int minY = level.getMinBuildHeight();
|
||||||
|
+ final int minZ = MathUtility.safeDoubleToInt(worldBorder.getMinZ());
|
||||||
|
+
|
||||||
|
+ return new BlockPos(MathUtility.clampInt(x, minX, maxX), MathUtility.clampInt(y, minY, maxY), MathUtility.clampInt(z, minZ, maxZ));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ catch (Exception e)
|
||||||
|
+ { // If we throw some sort of exception due to the position being crazy, catch it
|
||||||
|
+ return new BlockPos(0, 0, 0);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
313
patches/server/0024-Reset-large-tags.patch
Normal file
313
patches/server/0024-Reset-large-tags.patch
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Mon, 18 Apr 2022 03:56:09 +0100
|
||||||
|
Subject: [PATCH] Reset large tags
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||||
|
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..04c47cf1a920ae6c356449df801227ee14f6dfb7 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; // Scissors
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
|
@@ -22,10 +23,12 @@ public class ContainerHelper {
|
||||||
|
|
||||||
|
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
||||||
|
ListTag listTag = new ListTag();
|
||||||
|
+ long total = 0; // Scissors
|
||||||
|
|
||||||
|
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 +36,7 @@ public class ContainerHelper {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!listTag.isEmpty() || setIfEmpty) {
|
||||||
|
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) { // Scissors
|
||||||
|
nbt.put("Items", listTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -42,11 +45,19 @@ public class ContainerHelper {
|
||||||
|
|
||||||
|
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
|
||||||
|
ListTag listTag = nbt.getList("Items", 10);
|
||||||
|
+ long total = 0; // Scissors - Account for items inside containers
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
+ // Scissors start
|
||||||
|
+ total += NbtUtility.getTagSize(compoundTag);
|
||||||
|
+ if (total >= NbtUtility.MAXIMUM_SIZE) {
|
||||||
|
+ stacks.clear();
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
stacks.set(j, ItemStack.of(compoundTag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
index de277d61b718fe07a87d75a2547bb1c7f8553aa1..e2dbfe581717cc107d89206c1ba46014a6965693 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
@@ -23,6 +23,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; // Scissors
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.advancements.CriteriaTriggers;
|
||||||
|
@@ -277,6 +278,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)) {
|
||||||
|
@@ -584,7 +591,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;
|
||||||
|
@@ -918,6 +929,7 @@ public final class ItemStack {
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
public void setTag(@Nullable CompoundTag nbt) {
|
||||||
|
+ if (NbtUtility.isTooLarge(nbt)) return; // Scissors - Ignore large tags
|
||||||
|
this.tag = nbt;
|
||||||
|
this.processEnchantOrder(this.tag); // Paper
|
||||||
|
if (this.getItem().canBeDepleted()) {
|
||||||
|
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 f5ad7ddf13cbb6452c2927aef9b54eae3335b4c6..041e3c8fb7c9ca69a7c7c1c952ed9915a75d7752 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; // Scissors
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
@@ -212,6 +213,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||||
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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..a9a8c9e68e5b767dec2c26495685da88e0caa627 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; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
@@ -34,6 +35,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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 c57efcb9a79337ec791e4e8f6671612f0a82b441..2cbb8170953cb555411db8c171a3d1d91eb799bb 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; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
@@ -73,6 +74,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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..f51abf1722e98d7ce9e616d84472d847e597eafb 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; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
@@ -40,6 +41,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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..d0513b72cdaec3b67b9341d251367b193bafa40c 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; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@@ -28,6 +29,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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 d4dcf7fe26474ae07374e7761d823bc5c8b54f97..7352183f7eaa1ddcd028e53f4b66a1c34e32b988 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
|
||||||
|
@@ -6,6 +6,7 @@ import java.util.function.BooleanSupplier;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
@@ -56,6 +57,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
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 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..9f12fbcd8d0c75de1d8c06bed2c64a0acdc877c9 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
|
||||||
|
@@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+import me.totalfreedom.scissors.NbtUtility; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
@@ -61,6 +62,17 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||||
|
public boolean opened;
|
||||||
|
|
||||||
|
public List<ItemStack> getContents() {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
return this.itemStacks;
|
||||||
|
}
|
||||||
|
|
19
patches/server/0025-Don-t-log-invalid-teams-to-console.patch
Normal file
19
patches/server/0025-Don-t-log-invalid-teams-to-console.patch
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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 8c81cd6a6563e4eb46a26c30baa3dfd9df3ecf1f..b01c443746f0c4c8c37fb5955351eff1689be1c4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
|
@@ -860,7 +860,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||||
|
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 - Prevent log spam possible with this error message, easily provokable by players in creative.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Fri, 19 Aug 2022 00:49:38 -0600
|
||||||
|
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 5f4c42c4ba44923cabb873bfad33abc2b1362e73..6608c98d1a517c307e16669e536dda6eb9f1e082 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||||
|
@@ -279,6 +279,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 {
|
159
patches/server/0027-Add-MasterBlockFireEvent.patch
Normal file
159
patches/server/0027-Add-MasterBlockFireEvent.patch
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 18:11:55 -0600
|
||||||
|
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 7ef14e4441a329c680a5dfe4bfb5033ffcb8f9d5..eff5bdf00b0aa7a9925ff59a62ead72509dc67b8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||||
|
@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils;
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@@ -28,6 +29,7 @@ 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.Location;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||||
|
@@ -130,6 +132,14 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
||||||
|
+ // Scissors start - 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/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||||
|
index 3a210e138b6ae065fd32e1b1e0e49999e20c4667..183c47a6fbf5201c38d5eb182049643862ca0964 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";
|
||||||
|
@@ -131,6 +134,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||||
|
+ // Scissors start - 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 60c941bd67dc899ea923f8ee49412de01ce199db..9bcd07f8b5d266c39034e5c021da9ffb7262b474 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;
|
||||||
|
@@ -261,7 +264,7 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
BlockPos blockPos = this.getBlockPos();
|
||||||
|
- int i = 80;
|
||||||
|
+ // Scissors - Obfuscation fixes
|
||||||
|
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);
|
||||||
|
@@ -320,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
if (this.structureName == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
+ // Scissors start - 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();
|
||||||
|
@@ -371,6 +384,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
if (structureTemplate == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
+ // Scissors start - 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
|
||||||
|
+
|
||||||
|
this.loadStructureInfo(structureTemplate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -407,6 +430,15 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadStructure() {
|
||||||
|
+ // Scissors start - 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();
|
30
patches/server/0028-Add-spectator-teleport-event.patch
Normal file
30
patches/server/0028-Add-spectator-teleport-event.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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 64255f7db85886421d5029766e8a6d1eadb94cff..2a3f4e6bfc6b122bb2102163381de8c78f06f1b5 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; // Scissors
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.primitives.Floats;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
@@ -2037,6 +2038,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
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;
|
||||||
|
}
|
37
patches/server/0029-Prevent-invalid-container-events.patch
Normal file
37
patches/server/0029-Prevent-invalid-container-events.patch
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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 2a3f4e6bfc6b122bb2102163381de8c78f06f1b5..2ac044f9e4c4c80263a34f9294cb69829bca132e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -29,6 +29,7 @@ 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; // Scissors
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
@@ -2909,6 +2910,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
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,73 @@
|
|||||||
|
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/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
index 31911c09fe15753ae32fa39417bdc9e9de552a88..b810a5afcb2343174e37efb7dd8a36b968b07c3a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
@@ -2,6 +2,7 @@ package net.minecraft.world.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
@@ -9,8 +10,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.*; // Scissors
|
||||||
|
import net.minecraft.stats.Stats;
|
||||||
|
import net.minecraft.util.StringUtil;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@@ -161,9 +161,43 @@ 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) {
|
||||||
|
return true;
|
@ -0,0 +1,31 @@
|
|||||||
|
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/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 2ac044f9e4c4c80263a34f9294cb69829bca132e..889f142b6f87d4ccf4c1d2ffd379c96fbbfddd44 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -1265,7 +1265,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
if (this.player.hasPermissions(2)) {
|
||||||
|
Entity entity = this.player.level().getEntity(packet.getEntityId());
|
||||||
|
|
||||||
|
- if (entity != null) {
|
||||||
|
+ if (entity != null && this.player.distanceToSqr(entity.position().x, entity.position().y, entity.position().z) < 32 * 32) { // Scissors - Validate entity tag query positions
|
||||||
|
CompoundTag nbttagcompound = entity.saveWithoutId(new CompoundTag());
|
||||||
|
|
||||||
|
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));
|
||||||
|
@@ -1297,7 +1297,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
@Override
|
||||||
|
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
- if (this.player.hasPermissions(2)) {
|
||||||
|
+ // Scissors start - Validate block entity tag query positions
|
||||||
|
+ if (this.player.hasPermissions(2) && this.player.level().isLoadedAndInBounds(packet.getPos())
|
||||||
|
+ && this.player.distanceToSqr(packet.getPos().getX(), packet.getPos().getY(), packet.getPos().getZ()) < 32 * 32) {
|
||||||
|
+ // Scissors end
|
||||||
|
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
|
||||||
|
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||||
|
|
@ -0,0 +1,67 @@
|
|||||||
|
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/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||||
|
index a3ec2f522be2d02b9e37810799cecc2ba14f58f3..97d4d9f85ee20aa1dd894d24deefe33478fe1cee 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
|
||||||
|
@@ -8,8 +8,10 @@ import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||||
|
import net.minecraft.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
+import net.minecraft.commands.Commands; // Scissors
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
@@ -19,6 +21,7 @@ import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.ComponentUtils;
|
||||||
|
import net.minecraft.network.chat.Style;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
|
+import net.minecraft.server.MinecraftServer; // Scissors
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.server.network.FilteredText;
|
||||||
|
@@ -32,6 +35,7 @@ import net.minecraft.world.level.block.SignBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.Vec2;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity; // Scissors
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.bukkit.block.sign.Side;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
|
@@ -39,6 +43,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
// CraftBukkit end
|
||||||
|
+import org.bukkit.craftbukkit.CraftServer; // Scissors
|
||||||
|
|
||||||
|
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
||||||
|
|
||||||
|
@@ -289,6 +294,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||||
|
}
|
||||||
|
player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
||||||
|
// Paper end
|
||||||
|
+ // Scissors start - Add optional permissions to command signs
|
||||||
|
+ final MinecraftServer vanillaServer = player.getServer();
|
||||||
|
+ final CraftServer craftServer = vanillaServer.server;
|
||||||
|
+ final CraftHumanEntity craftPlayer = player.getBukkitEntity();
|
||||||
|
+ final Commands commands = vanillaServer.getCommands();
|
||||||
|
+
|
||||||
|
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
||||||
|
+ {
|
||||||
|
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
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 730d8e3cf2d9ca05b2d6219cf1856b8721871a37..63e71c5cb4ac4d17d2cfa5324fd842a0d3c61eb5 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||||
|
@@ -198,6 +198,7 @@ public final class CraftChatMessage {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
||||||
|
+ if (message.length() > 1_000) return new Component[]{Component.empty()}; // Scissors - Refuse to convert legacy messages over 1k characters
|
||||||
|
return new StringMessage(message, keepNewlines, plain).getOutput();
|
||||||
|
}
|
||||||
|
|
100
patches/server/0034-Prevent-velocity-freeze.patch
Normal file
100
patches/server/0034-Prevent-velocity-freeze.patch
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 18:41:18 -0600
|
||||||
|
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 c4ecc5faa4f61e7974e8c475762924a89615b377..1c14b87f84b678b36adede9d2aa9a18453ce4278 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||||
|
@@ -1,6 +1,8 @@
|
||||||
|
package net.minecraft.world.entity.projectile;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import me.totalfreedom.scissors.MathUtility;
|
||||||
|
import net.minecraft.core.particles.ParticleOptions;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@@ -47,12 +49,15 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||||
|
// CraftBukkit end
|
||||||
|
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;
|
||||||
|
+ if (d6 != 0.0D)
|
||||||
|
+ {
|
||||||
|
+ // Scissors start - Prevent projectile velocity freeze
|
||||||
|
+ //this.xPower = d3 / d6 * 0.1D;
|
||||||
|
+ //this.yPower = d4 / d6 * 0.1D;
|
||||||
|
+ //this.zPower = d5 / d6 * 0.1D;
|
||||||
|
+ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d);
|
||||||
|
}
|
||||||
|
-
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractHurtingProjectile(EntityType<? extends AbstractHurtingProjectile> type, LivingEntity owner, double directionX, double directionY, double directionZ, Level world) {
|
||||||
|
@@ -164,6 +169,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 = 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);
|
||||||
|
@@ -171,9 +195,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);
|
||||||
|
+
|
||||||
|
+ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2));
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -207,9 +235,13 @@ 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);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,107 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 18:48:55 -0600
|
||||||
|
Subject: [PATCH] Add configuration option to disable chat signatures
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||||
|
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..939f4a0639c847b94cfc9acf1409a7a3fc5ae58f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.network.chat;
|
||||||
|
|
||||||
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
||||||
|
public interface OutgoingChatMessage {
|
||||||
|
@@ -44,10 +45,22 @@ public interface OutgoingChatMessage {
|
||||||
|
// Paper end
|
||||||
|
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
||||||
|
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
||||||
|
- if (!playerChatMessage.isFullyFiltered()) {
|
||||||
|
+ // Sccissors start
|
||||||
|
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
|
||||||
|
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
|
||||||
|
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
|
||||||
|
+ null,
|
||||||
|
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
|
||||||
|
+ unsigned,
|
||||||
|
+ playerChatMessage.filterMask(),
|
||||||
|
+ playerChatMessage.result()
|
||||||
|
+ ), params);
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||||
|
index 85a8a687b1568a56e3e646b37ef78b562c1b8a82..68e2edd39dcbcc9199aeaecff9b3280914ba9270 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||||
|
@@ -5,6 +5,8 @@ import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||||
|
import net.minecraft.util.SignatureUpdater;
|
||||||
|
import net.minecraft.util.SignatureValidator;
|
||||||
|
import net.minecraft.util.Signer;
|
||||||
|
@@ -46,7 +48,7 @@ public class SignedMessageChain {
|
||||||
|
if (!playerChatMessage.verify(signatureValidator)) {
|
||||||
|
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
|
||||||
|
} else {
|
||||||
|
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
|
||||||
|
+ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) { // Scissors
|
||||||
|
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", (Object)body.content());
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index 889f142b6f87d4ccf4c1d2ffd379c96fbbfddd44..4bdd2e731102c7e3a312ad3144537042dce46923 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.ScissorsConfig;
|
||||||
|
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.primitives.Floats;
|
||||||
|
@@ -2247,7 +2248,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
|
||||||
|
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||||
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to update secure chat state for {}: '{}'", this.player.getGameProfile().getName(), exception.getComponent().getString());
|
||||||
|
- if (exception.shouldDisconnect()) {
|
||||||
|
+ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled
|
||||||
|
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
|
||||||
|
} else {
|
||||||
|
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
|
||||||
|
@@ -2295,6 +2296,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
|
||||||
|
|
||||||
|
if (optional.isEmpty()) {
|
||||||
|
+ if (!ScissorsConfig.chatSignaturesEnabled) return optional; // Scissors
|
||||||
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||||
|
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
||||||
|
}
|
||||||
|
@@ -2493,6 +2495,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
|
||||||
|
synchronized (this.lastSeenMessages) {
|
||||||
|
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
||||||
|
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
|
||||||
|
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
||||||
|
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
||||||
|
}
|
||||||
|
@@ -3471,6 +3474,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
@Override
|
||||||
|
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
|
||||||
|
RemoteChatSession.Data remotechatsession_a = packet.chatSession();
|
||||||
|
ProfilePublicKey.Data profilepublickey_a = this.chatSession != null ? this.chatSession.profilePublicKey().data() : null;
|
||||||
|
ProfilePublicKey.Data profilepublickey_a1 = remotechatsession_a.profilePublicKey();
|
@ -0,0 +1,76 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Sun, 10 Dec 2023 18:57:50 -0600
|
||||||
|
Subject: [PATCH] Patch large selector distance crash
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||||
|
index d87ffb5ed4550757016c2fabaa2845a6aaac74d7..7e8cf65ac53f595292d161da0735bf97081e832a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||||
|
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||||
|
@@ -123,11 +123,11 @@ public interface MinMaxBounds<T extends Number> {
|
||||||
|
|
||||||
|
public static record Doubles(Optional<Double> min, Optional<Double> max, Optional<Double> minSq, Optional<Double> maxSq) implements MinMaxBounds<Double> {
|
||||||
|
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
|
||||||
|
- public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
|
||||||
|
+ public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.<Double, MinMaxBounds.Doubles>createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes
|
||||||
|
|
||||||
|
- private Doubles(Optional<Double> min, Optional<Double> max) {
|
||||||
|
+ public Doubles(Optional<Double> min, Optional<Double> max) {
|
||||||
|
this(min, max, squareOpt(min), squareOpt(max));
|
||||||
|
- }
|
||||||
|
+ } // Scissors - private -> public
|
||||||
|
|
||||||
|
private static MinMaxBounds.Doubles create(StringReader reader, Optional<Double> min, Optional<Double> max) throws CommandSyntaxException {
|
||||||
|
if (min.isPresent() && max.isPresent() && min.get() > max.get()) {
|
||||||
|
@@ -188,7 +188,7 @@ public interface MinMaxBounds<T extends Number> {
|
||||||
|
|
||||||
|
public static record Ints(Optional<Integer> min, Optional<Integer> max, Optional<Long> minSq, Optional<Long> maxSq) implements MinMaxBounds<Integer> {
|
||||||
|
public static final MinMaxBounds.Ints ANY = new MinMaxBounds.Ints(Optional.empty(), Optional.empty());
|
||||||
|
- public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new);
|
||||||
|
+ public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.<Integer, MinMaxBounds.Ints>createCodec(Codec.INT, MinMaxBounds.Ints::new); // Scissors - compile fixes
|
||||||
|
|
||||||
|
private Ints(Optional<Integer> min, Optional<Integer> max) {
|
||||||
|
this(min, max, min.map((i) -> {
|
||||||
|
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||||
|
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..f0a84efe86407ab3d7a9f064140c12df43265adc 100644
|
||||||
|
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||||
|
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||||
|
@@ -10,6 +10,8 @@ import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import me.totalfreedom.scissors.MathUtility;
|
||||||
|
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.commands.arguments.EntityArgument;
|
||||||
|
@@ -60,9 +62,26 @@ public class EntitySelector {
|
||||||
|
this.includesEntities = includesNonPlayers;
|
||||||
|
this.worldLimited = localWorldOnly;
|
||||||
|
this.predicate = basePredicate;
|
||||||
|
- this.range = distance;
|
||||||
|
+ // Scissors start - Patch large selector distance crash
|
||||||
|
+ this.range = new MinMaxBounds.Doubles(
|
||||||
|
+ distance.min().map(min -> Math.min(min, 1024)),
|
||||||
|
+ distance.max().map(max -> Math.min(max, 1024))
|
||||||
|
+ );
|
||||||
|
this.position = positionOffset;
|
||||||
|
- this.aabb = box;
|
||||||
|
+ if (box != null) {
|
||||||
|
+ this.aabb = new AABB(
|
||||||
|
+ MathUtility.clampDouble(box.minX, -1024, 1025),
|
||||||
|
+ MathUtility.clampDouble(box.minY, -1024, 1025),
|
||||||
|
+ MathUtility.clampDouble(box.minZ, -1024, 1025),
|
||||||
|
+ MathUtility.clampDouble(box.maxX, -1024, 1025),
|
||||||
|
+ MathUtility.clampDouble(box.maxY, -1024, 1025),
|
||||||
|
+ MathUtility.clampDouble(box.maxZ, -1024, 1025),
|
||||||
|
+ false
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ this.aabb = null;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
this.order = sorter;
|
||||||
|
this.currentEntity = senderOnly;
|
||||||
|
this.playerName = playerName;
|
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Mon, 20 Mar 2023 07:04:50 +0000
|
||||||
|
Subject: [PATCH] Patch invalid entity rotation log spam
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
index a8ae232f9ef204e6dd2f14c1e92008ceb7af7ab2..4f032b8303c6c1dc3c829c3c09009aaa0a5209fa 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -4734,7 +4734,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||||
|
|
||||||
|
public void setXRot(float pitch) {
|
||||||
|
if (!Float.isFinite(pitch)) {
|
||||||
|
- Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding.");
|
||||||
|
+ // Scissors - Patch invalid entity rotation log spam
|
||||||
|
} else {
|
||||||
|
this.xRot = pitch;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Mon, 10 Apr 2023 13:56:18 -0300
|
||||||
|
Subject: [PATCH] Limit sculk catalyst cursor positions
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||||
|
index 01e13e6d3ebd84cff0019f56efff16747420dc95..d4058bc31ca291cbc95eeef594fc35e1ff6a3dde 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||||
|
@@ -181,7 +181,7 @@ public class SculkSpreader {
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
SculkSpreader.ChargeCursor sculkspreader_a = (SculkSpreader.ChargeCursor) iterator.next();
|
||||||
|
-
|
||||||
|
+ if (!world.getMinecraftWorld().isLoadedAndInBounds(sculkspreader_a.getPos())) continue; // Scissors
|
||||||
|
sculkspreader_a.update(world, pos, random, this, shouldConvertToBlock);
|
||||||
|
if (sculkspreader_a.charge <= 0) {
|
||||||
|
world.levelEvent(3006, sculkspreader_a.getPos(), 0);
|
36
patches/server/0039-Limit-map-decorations.patch
Normal file
36
patches/server/0039-Limit-map-decorations.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Fri, 28 Apr 2023 16:29:23 -0300
|
||||||
|
Subject: [PATCH] Limit map decorations
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||||
|
index 17343d515044f3678b4edf070ee7ca244adc4228..8ade519114bec879bed8e8e23707a85327da131b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||||
|
@@ -65,7 +65,8 @@ public class ClientboundMapItemDataPacket implements Packet<ClientGamePacketList
|
||||||
|
b.writeByte(icon.x());
|
||||||
|
b.writeByte(icon.y());
|
||||||
|
b.writeByte(icon.rot() & 15);
|
||||||
|
- b.writeNullable(icon.name(), FriendlyByteBuf::writeComponent);
|
||||||
|
+ final boolean passedNameCap = icon.name() == null || icon.name().getString().length() <= 32; // Scissors
|
||||||
|
+ b.writeNullable(passedNameCap ? icon.name() : null, FriendlyByteBuf::writeComponent); // Scissors
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (this.colorPatch != null) {
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
index e4c4948e076cd64686dfd16ae0568fafc1437140..eff53c21b18574750b691b784fb1688885d4ace7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||||
|
@@ -361,6 +361,11 @@ public class MapItemSavedData extends SavedData {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
|
||||||
|
+ // Scissors start - Limit decoration count
|
||||||
|
+ if (this.decorations.size() > 32) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
int i = 1 << this.scale;
|
||||||
|
float f = (float) (x - (double) this.centerX) / (float) i;
|
||||||
|
float f1 = (float) (z - (double) this.centerZ) / (float) i;
|
@ -0,0 +1,25 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Fri, 28 Apr 2023 16:44:50 -0300
|
||||||
|
Subject: [PATCH] Prevent player banning using duplicate UUIDs
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index 9c2a2e441eb7efeee0caaec442158a66acfe8cc6..1ae51a64ede4bb74356737474050eceb350e4c8f 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -1688,7 +1688,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||||
|
if (entity != null) {
|
||||||
|
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID());
|
||||||
|
entity.unRide();
|
||||||
|
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
|
||||||
|
+ // Scissors start - Prevent player banning using duplicate UUIDs
|
||||||
|
+ if (entity instanceof ServerPlayer serverPlayer) {
|
||||||
|
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
|
||||||
|
+ } else {
|
||||||
|
+ entity.discard();
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system
|
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Fri, 28 Apr 2023 16:46:00 -0300
|
||||||
|
Subject: [PATCH] Don't warn on duplicate entity UUIDs
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||||
|
index 15ee41452992714108efe53b708b5a4e1da7c1ff..5054dce35127cb0132431021578c345fcbb1f92a 100644
|
||||||
|
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||||
|
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||||
|
@@ -415,7 +415,7 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.entityByUUID.containsKey(entity.getUUID())) {
|
||||||
|
- LOGGER.warn("Entity uuid already exists: " + entity.getUUID() + ", mapped to " + this.entityByUUID.get(entity.getUUID()) + ", can't add " + entity);
|
||||||
|
+ // Scissors - Don't warn on duplicate entity UUIDs
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.entityById.put(entity.getId(), entity);
|
86
patches/server/0042-Implement-command-block-events.patch
Normal file
86
patches/server/0042-Implement-command-block-events.patch
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Mon, 11 Dec 2023 12:27:44 -0600
|
||||||
|
Subject: [PATCH] Implement command block events
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||||
|
index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400deb533d2 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
|
||||||
|
@@ -9,7 +9,7 @@ import net.minecraft.world.level.BaseCommandBlock;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
public class ServerboundSetCommandMinecartPacket implements Packet<ServerGamePacketListener> {
|
||||||
|
- private final int entity;
|
||||||
|
+ public final int entity; // Scissors - private -> public
|
||||||
|
private final String command;
|
||||||
|
private final boolean trackOutput;
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index 4bdd2e731102c7e3a312ad3144537042dce46923..1f7dc235f8cf848d740ef6a8cf879d253b56c1c8 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -1,6 +1,8 @@
|
||||||
|
package net.minecraft.server.network;
|
||||||
|
|
||||||
|
import me.totalfreedom.scissors.ScissorsConfig;
|
||||||
|
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
|
||||||
|
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
|
||||||
|
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.primitives.Floats;
|
||||||
|
@@ -155,6 +157,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.entity.player.ProfilePublicKey;
|
||||||
|
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||||
|
import net.minecraft.world.entity.vehicle.Boat;
|
||||||
|
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock;
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.inventory.AnvilMenu;
|
||||||
|
import net.minecraft.world.inventory.BeaconMenu;
|
||||||
|
@@ -189,6 +192,8 @@ import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||||
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
+import org.bukkit.craftbukkit.block.CraftCommandBlock;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
@@ -894,6 +899,16 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start
|
||||||
|
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level().getWorld(), tileentitycommand));
|
||||||
|
+
|
||||||
|
+ if (!event.callEvent()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ s = event.getNewCommand();
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
commandblocklistenerabstract.setCommand(s);
|
||||||
|
commandblocklistenerabstract.setTrackOutput(flag);
|
||||||
|
if (!flag) {
|
||||||
|
@@ -925,7 +940,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
|
||||||
|
|
||||||
|
if (commandblocklistenerabstract != null) {
|
||||||
|
- commandblocklistenerabstract.setCommand(packet.getCommand());
|
||||||
|
+ // Scissors start - Implement command block events
|
||||||
|
+ String command = packet.getCommand();
|
||||||
|
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), command, new CraftMinecartCommand(this.cserver, (MinecartCommandBlock) this.player.level().getEntity(packet.entity)));
|
||||||
|
+
|
||||||
|
+ if (!event.callEvent()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ command = event.getNewCommand();
|
||||||
|
+ commandblocklistenerabstract.setCommand(command);
|
||||||
|
+
|
||||||
|
+ // Scissors end
|
||||||
|
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
|
||||||
|
if (!packet.isTrackOutput()) {
|
||||||
|
commandblocklistenerabstract.setLastOutput((Component) null);
|
110
patches/server/0043-Add-depth-limit-to-SNBT.patch
Normal file
110
patches/server/0043-Add-depth-limit-to-SNBT.patch
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Fri, 2 Jun 2023 22:13:54 +0100
|
||||||
|
Subject: [PATCH] Add depth limit to SNBT
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||||
|
index 5bec54239a2b185284c10d58854e5a13e33daae5..f112d82b0a9e5513395fa7c1b05d1fe9e28c64ca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||||
|
@@ -179,9 +179,56 @@ public class TagParser {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.expect('}');
|
||||||
|
- return compoundTag;
|
||||||
|
+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag; // Scissors - Add depth limit to SNBT
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Scissors start - Add depth limit to SNBT
|
||||||
|
+ private boolean exceedsDepthLimit(Tag tag) {
|
||||||
|
+ return this.exceedsDepthLimit(0, tag);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private boolean exceedsDepthLimit(long depth, Tag tag)
|
||||||
|
+ {
|
||||||
|
+ if (depth > 256)
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (tag instanceof ListTag listTag)
|
||||||
|
+ {
|
||||||
|
+ for (Tag childTag : listTag)
|
||||||
|
+ {
|
||||||
|
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
||||||
|
+
|
||||||
|
+ if (returnValue)
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else if (tag instanceof CompoundTag compoundTag)
|
||||||
|
+ {
|
||||||
|
+ for (String key: compoundTag.getAllKeys())
|
||||||
|
+ {
|
||||||
|
+ Tag childTag = compoundTag.get(key);
|
||||||
|
+
|
||||||
|
+ if (childTag == null)
|
||||||
|
+ {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
||||||
|
+
|
||||||
|
+ if (returnValue)
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
private Tag readListTag() throws CommandSyntaxException {
|
||||||
|
this.expect('[');
|
||||||
|
this.reader.skipWhitespace();
|
||||||
|
@@ -213,7 +260,7 @@ public class TagParser {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.expect(']');
|
||||||
|
- return listTag;
|
||||||
|
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; // Scissors - Add depth limit to SNBT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -238,7 +285,7 @@ public class TagParser {
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Number> List<T> readArray(TagType<?> arrayTypeReader, TagType<?> typeReader) throws CommandSyntaxException {
|
||||||
|
- List<T> list = Lists.newArrayList();
|
||||||
|
+ List<Number> list = Lists.newArrayList(); // Scissors - List<T> -> List<Number>
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
if (this.reader.peek() != ']') {
|
||||||
|
@@ -251,11 +298,11 @@ public class TagParser {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeReader == ByteTag.TYPE) {
|
||||||
|
- list.add((T)((NumericTag)tag).getAsByte());
|
||||||
|
+ list.add(((NumericTag)tag).getAsByte()); // Scissors - Remove (T) cast
|
||||||
|
} else if (typeReader == LongTag.TYPE) {
|
||||||
|
- list.add((T)((NumericTag)tag).getAsLong());
|
||||||
|
+ list.add(((NumericTag)tag).getAsLong()); // Scissors - Remove (T) cast
|
||||||
|
} else {
|
||||||
|
- list.add((T)((NumericTag)tag).getAsInt());
|
||||||
|
+ list.add(((NumericTag)tag).getAsInt()); // Scissors - Remove (T) cast
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.hasElementSeparator()) {
|
||||||
|
@@ -267,7 +314,7 @@ public class TagParser {
|
||||||
|
}
|
||||||
|
|
||||||
|
this.expect(']');
|
||||||
|
- return list;
|
||||||
|
+ return (List<T>) list; // Scissors - Cast to List<T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
27
patches/server/0044-Limit-beacon-effectRange.patch
Normal file
27
patches/server/0044-Limit-beacon-effectRange.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Wed, 7 Jun 2023 16:50:35 -0300
|
||||||
|
Subject: [PATCH] Limit beacon effectRange
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||||
|
index f13943db6f2fb923c52dcf9e8bf7000041d0a362..2fdcc47dd6a813d5f7a32dc58ca67b6b965c8749 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
|
||||||
|
@@ -87,7 +87,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||||
|
private double effectRange = -1;
|
||||||
|
|
||||||
|
public double getEffectRange() {
|
||||||
|
- if (this.effectRange < 0) {
|
||||||
|
+ if (this.effectRange < 0 || this.effectRange > 256) { // Scissors
|
||||||
|
return this.levels * 10 + 10;
|
||||||
|
} else {
|
||||||
|
return effectRange;
|
||||||
|
@@ -456,6 +456,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||||
|
|
||||||
|
this.lockKey = LockCode.fromTag(nbt);
|
||||||
|
this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
||||||
|
+ if (this.effectRange > 256) this.effectRange = 256; // Scissors
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
@ -0,0 +1,18 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Tue, 13 Jun 2023 18:29:18 -0300
|
||||||
|
Subject: [PATCH] Improve validation of ResourceLocations
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||||
|
index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
|
||||||
|
@@ -21,6 +21,7 @@ public final class CraftNamespacedKey {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
|
||||||
|
+ if (minecraft == null) throw new IllegalArgumentException("Null ResourceLocation provided"); // Scissors
|
||||||
|
return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Sat, 1 Jul 2023 21:22:29 -0300
|
||||||
|
Subject: [PATCH] Don't log on too many chained updates
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||||
|
index 598dc0d3a2b9387e76d7e4e19e54c4573a24bc54..9eed28bf8bc7e2fa528729cde01a535bc7040815 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
||||||
|
@@ -56,7 +56,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
||||||
|
this.stack.push(entry);
|
||||||
|
}
|
||||||
|
} else if (this.count - 1 == this.maxChainedNeighborUpdates) {
|
||||||
|
- LOGGER.error("Too many chained neighbor updates. Skipping the rest. First skipped position: " + pos.toShortString());
|
||||||
|
+ // Scissors - don't log
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bl) {
|
46
patches/server/0047-Fix-packet-related-lag-exploits.patch
Normal file
46
patches/server/0047-Fix-packet-related-lag-exploits.patch
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Tue, 4 Jul 2023 18:49:34 -0300
|
||||||
|
Subject: [PATCH] Fix packet-related lag exploits
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
index 1f7dc235f8cf848d740ef6a8cf879d253b56c1c8..2ef6fd0fadaf6b912c4f242210c1ce2756ccddd7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
|
@@ -859,7 +859,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
|
||||||
|
} else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
|
||||||
|
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
|
||||||
|
- } else {
|
||||||
|
+ } else if (this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||||
|
BaseCommandBlock commandblocklistenerabstract = null;
|
||||||
|
CommandBlockEntity tileentitycommand = null;
|
||||||
|
BlockPos blockposition = packet.getPos();
|
||||||
|
@@ -1026,7 +1026,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
@Override
|
||||||
|
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
- if (this.player.canUseGameMasterBlocks()) {
|
||||||
|
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||||
|
BlockPos blockposition = packet.getPos();
|
||||||
|
BlockState iblockdata = this.player.level().getBlockState(blockposition);
|
||||||
|
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||||
|
@@ -1084,7 +1084,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
@Override
|
||||||
|
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
- if (this.player.canUseGameMasterBlocks()) {
|
||||||
|
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||||
|
BlockPos blockposition = packet.getPos();
|
||||||
|
BlockState iblockdata = this.player.level().getBlockState(blockposition);
|
||||||
|
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||||
|
@@ -1109,7 +1109,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||||
|
@Override
|
||||||
|
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
|
||||||
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||||
|
- if (this.player.canUseGameMasterBlocks()) {
|
||||||
|
+ if (this.player.canUseGameMasterBlocks() && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||||
|
BlockPos blockposition = packet.getPos();
|
||||||
|
BlockEntity tileentity = this.player.level().getBlockEntity(blockposition);
|
||||||
|
|
44
patches/server/0048-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
44
patches/server/0048-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Wed, 5 Jul 2023 22:58:24 +0100
|
||||||
|
Subject: [PATCH] Limit save data for Bees and Vexes
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
index a87a34b0c4c8e5d0cf079025c230b1434c919b54..7cbcbbed6ec45a32bbfe8118bf186c6580f065ca 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||||
|
@@ -234,8 +234,12 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||||
|
@Override
|
||||||
|
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
this.hivePos = null;
|
||||||
|
- if (nbt.contains("HivePos")) {
|
||||||
|
- this.hivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||||
|
+ if (nbt.contains("HivePos"))
|
||||||
|
+ {
|
||||||
|
+ // Scissors start - Limit HivePos
|
||||||
|
+ final BlockPos savedHivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||||
|
+ this.hivePos = this.level().isLoadedAndInBounds(savedHivePos) ? savedHivePos : null;
|
||||||
|
+ // Scissors end - Limit HivePos
|
||||||
|
}
|
||||||
|
|
||||||
|
this.savedFlowerPos = null;
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
index 30ea3f64234fd1fda8dada3c7fb12be0730322a8..b621b9a50047c5283b259d67019989ec823576e0 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||||
|
@@ -118,8 +118,12 @@ public class Vex extends Monster implements TraceableEntity {
|
||||||
|
@Override
|
||||||
|
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
super.readAdditionalSaveData(nbt);
|
||||||
|
- if (nbt.contains("BoundX")) {
|
||||||
|
- this.boundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||||
|
+ if (nbt.contains("BoundX"))
|
||||||
|
+ {
|
||||||
|
+ // Scissors start - Limit Vex bound origin
|
||||||
|
+ final BlockPos savedBoundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||||
|
+ this.boundOrigin = this.level().isLoadedAndInBounds(savedBoundOrigin) ? savedBoundOrigin : null;
|
||||||
|
+ // Scissors end - Limit Vex bound origin
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbt.contains("LifeTicks")) {
|
32
patches/server/0049-Mute-invalid-attributes.patch
Normal file
32
patches/server/0049-Mute-invalid-attributes.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Thu, 6 Jul 2023 23:01:12 +0100
|
||||||
|
Subject: [PATCH] Mute invalid attributes
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||||
|
index 7204b973c3ad9239e82355513f6d538107102e48..2463444778f19f937b18173798c04d9d9788a824 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||||
|
@@ -147,7 +147,7 @@ public class AttributeMap {
|
||||||
|
}
|
||||||
|
|
||||||
|
}, () -> {
|
||||||
|
- LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string);
|
||||||
|
+ // LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string); // Scissors - Mute invalid attributes
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||||
|
index 1b0db545f93b51368c2d384dd1ba45b93d9eff87..5c3633aa6a256a197502c8139cbf61c2f493bda7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||||
|
@@ -86,7 +86,7 @@ public class AttributeModifier {
|
||||||
|
AttributeModifier.Operation operation = AttributeModifier.Operation.fromValue(nbt.getInt("Operation"));
|
||||||
|
return new AttributeModifier(uUID, nbt.getString("Name"), nbt.getDouble("Amount"), operation);
|
||||||
|
} catch (Exception var3) {
|
||||||
|
- LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage());
|
||||||
|
+ // LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage()); // Scissors - Mute invalid attributes
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
32
patches/server/0050-Mute-invalid-Enderdragon-phases.patch
Normal file
32
patches/server/0050-Mute-invalid-Enderdragon-phases.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Thu, 6 Jul 2023 23:34:46 +0100
|
||||||
|
Subject: [PATCH] Mute invalid Enderdragon phases
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||||
|
index bca131e9c428e2cb073ae2ef517dda12f73a5dcd..b9d603c82b12299e94c31928b36c9517834cff62 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||||
|
@@ -20,7 +20,7 @@ public class DragonChargePlayerPhase extends AbstractDragonPhaseInstance {
|
||||||
|
@Override
|
||||||
|
public void doServerTick() {
|
||||||
|
if (this.targetLocation == null) {
|
||||||
|
- LOGGER.warn("Aborting charge player as no target was set.");
|
||||||
|
+ // LOGGER.warn("Aborting charge player as no target was set."); // Scissors - Mute invalid Enderdragon phases
|
||||||
|
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||||
|
} else if (this.timeSinceCharge > 0 && this.timeSinceCharge++ >= 10) {
|
||||||
|
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||||
|
index a3456b35db4e938f91d6bc32d4d202a011bf13c4..aad0b066e4fd63195aa117c5a03f64846bf46fbd 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||||
|
@@ -32,7 +32,7 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance {
|
||||||
|
@Override
|
||||||
|
public void doServerTick() {
|
||||||
|
if (this.attackTarget == null) {
|
||||||
|
- LOGGER.warn("Skipping player strafe phase because no player was found");
|
||||||
|
+ // LOGGER.warn("Skipping player strafe phase because no player was found"); // Scissors - Mute invalid Enderdragon phases
|
||||||
|
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||||
|
} else {
|
||||||
|
if (this.currentPath != null && this.currentPath.isDone()) {
|
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Fri, 25 Aug 2023 11:51:47 +0100
|
||||||
|
Subject: [PATCH] Add length limit to note block sound
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
|
index 4430520d32024d897c93c1d9f8652ccb2c202c01..ceef1a7fd41751f553f21784217f95a210bd24d9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SkullBlockEntity.java
|
||||||
|
@@ -113,7 +113,7 @@ public class SkullBlockEntity extends BlockEntity {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbt.contains("note_block_sound", 8)) {
|
||||||
|
- this.noteBlockSound = ResourceLocation.tryParse(nbt.getString("note_block_sound"));
|
||||||
|
+ this.noteBlockSound = ResourceLocation.tryParse(StringUtil.truncateStringIfNecessary(nbt.getString("note_block_sound"), 32767, false)); // Scissors - Add length limit to note block sound
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user