Here we go 1.19.4

This commit is contained in:
Cryptite
2023-04-10 07:26:32 -05:00
parent 67fbb12ac6
commit 00bd3e0d3c
37 changed files with 9 additions and 2461 deletions

View File

@@ -3,8 +3,8 @@ import io.papermc.paperweight.util.constants.*
plugins { plugins {
java java
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") version "7.1.2" apply false id("com.github.johnrengelman.shadow") version "8.1.0" apply false
id("io.papermc.paperweight.patcher") version "1.3.9" id("io.papermc.paperweight.patcher") version "1.5.4"
} }
val paperMavenPublicUrl = "https://papermc.io/repo/repository/maven-public/" val paperMavenPublicUrl = "https://papermc.io/repo/repository/maven-public/"
@@ -17,9 +17,9 @@ repositories {
} }
dependencies { dependencies {
remapper("net.fabricmc:tiny-remapper:0.8.2:fat") remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
decompiler("net.minecraftforge:forgeflower:1.5.605.7") decompiler("net.minecraftforge:forgeflower:2.0.627.2")
paperclip("io.papermc:paperclip:3.0.2") paperclip("io.papermc:paperclip:3.0.3")
} }
allprojects { allprojects {

View File

@@ -1,8 +1,8 @@
group=com.lokamc.slice group=com.lokamc.slice
version=1.19.2-R0.1-SNAPSHOT version=1.19.4-R0.1-SNAPSHOT
mcVersion=1.19.2 mcVersion=1.19.4
paperRef=96fdafd9354f1d27d56ccc1cf7276f1552182659 paperRef=e811927394ffbccd7f63cde0d9063b3a2fe6bb98
org.gradle.caching=true org.gradle.caching=true
org.gradle.parallel=true org.gradle.parallel=true

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -1,39 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:20:02 -0500
Subject: [PATCH] Set BlockData without light updates
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index 9930ebe7a23d306c602840fd43652fbdaba481b3..ed65bb8867bc2b8e67726dee07a82ac3671b0306 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -297,6 +297,28 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
*/
void setBlockData(@NotNull BlockData data, boolean applyPhysics);
+ /**
+ * Sets the complete data for this block
+ *
+ * <br>
+ * Note that applyPhysics = false is not in general safe. It should only be
+ * used when you need to avoid triggering a physics update of neighboring
+ * blocks, for example when creating a {@link Bisected} block. If you are
+ * using a custom populator, then this parameter may also be required to
+ * prevent triggering infinite chunk loads on border blocks. This method
+ * should NOT be used to "hack" physics by placing blocks in impossible
+ * locations. Such blocks are liable to be removed on various events such as
+ * world upgrades. Furthermore setting large amounts of such blocks in close
+ * proximity may overload the server physics engine if an update is
+ * triggered at a later point. If this occurs, the resulting behavior is
+ * undefined.
+ *
+ * @param data new block specific data
+ * @param applyPhysics false to cancel physics from the changed block
+ * @param checkLight false to prevent a light-check update
+ */
+ void setBlockData(@NotNull BlockData data, boolean applyPhysics, boolean checkLight);
+
/**
* Sets the type of this block
*

View File

@@ -1,79 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 09:54:07 -0500
Subject: [PATCH] Add BlockDestroyedByNeighborEvent
diff --git a/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7db2789d54a609b023ea6deff87b45d717aabbf0
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/block/BlockDestroyedByNeighborEvent.java
@@ -0,0 +1,67 @@
+package io.papermc.paper.event.block;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.block.BlockEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a block is broken another block. This is generally the result of BlockPhysicsEvent propagation
+ */
+public class BlockDestroyedByNeighborEvent extends BlockEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private final Block sourceBlock;
+ private boolean cancel;
+
+ public BlockDestroyedByNeighborEvent(@NotNull final Block theBlock, @Nullable Player player, @NotNull final Block sourceBlock) {
+ super(theBlock);
+
+ this.player = player;
+ this.sourceBlock = sourceBlock;
+ }
+
+ /**
+ * Gets the Player that caused this
+ *
+ * @return The Player that is breaking the block involved in this event
+ */
+ @Nullable
+ public Player getPlayer() {
+ return player;
+ }
+
+ /**
+ * Gets the source block that caused this block break
+ *
+ * @return The Source Block which block is involved in this event
+ */
+ @NotNull
+ public final Block getSourceBlock() {
+ return sourceBlock;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:40:48 -0500
Subject: [PATCH] Add provided Material to getDrops
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
index ed65bb8867bc2b8e67726dee07a82ac3671b0306..3da43fba552b1cb16b9a5480c46a5d0ea0f9c087 100644
--- a/src/main/java/org/bukkit/block/Block.java
+++ b/src/main/java/org/bukkit/block/Block.java
@@ -639,6 +639,20 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
@NotNull
Collection<ItemStack> getDrops(@NotNull ItemStack tool, @Nullable Entity entity);
+ // Slice start
+ /**
+ * Returns a list of items which would drop by the entity destroying this
+ * block as though it were a given Material with a specific tool
+ *
+ * @param blockType The block type to use as the source loot
+ * @param tool The tool or item in hand used for digging
+ * @param entity the entity destroying the block
+ * @return a list of dropped items for this type of block
+ */
+ @NotNull
+ Collection<ItemStack> getDrops(@NotNull Material blockType, @NotNull ItemStack tool, @Nullable Entity entity);
+ // Slice end
+
/**
* Returns if the given item is a preferred choice to break this Block.
*

View File

@@ -1,52 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:41:44 -0500
Subject: [PATCH] Add Player to SpongeAbsorbEvent
diff --git a/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
index 7029cfcd00ed5d9c7f06898ec2b81238ec775a70..0e2f21e0f1983d2e8b67deebf4d12d25107d1582 100644
--- a/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
+++ b/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java
@@ -7,6 +7,7 @@ import org.bukkit.block.BlockState;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable; // Paper
/**
* Called when a sponge absorbs water from the world.
@@ -21,11 +22,13 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
+ private final org.bukkit.entity.Player player; // Paper
private final List<BlockState> blocks;
- public SpongeAbsorbEvent(@NotNull Block block, @NotNull List<BlockState> waterblocks) {
+ public SpongeAbsorbEvent(@NotNull Block block, @Nullable org.bukkit.entity.Player player, @NotNull List<BlockState> waterblocks) { // Paper
super(block);
this.blocks = waterblocks;
+ this.player = player; // Paper
}
/**
@@ -41,6 +44,18 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable {
return blocks;
}
+ // Paper start
+ /**
+ * Gets the Player that placed the Sponge Block
+ *
+ * @return The Player that placed the sponge block causing the absorb event, or null if no Player was involved
+ */
+ @Nullable
+ public org.bukkit.entity.Player getPlayer() {
+ return player;
+ }
+ // Paper end
+
@Override
public boolean isCancelled() {
return cancelled;

View File

@@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:45:51 -0500
Subject: [PATCH] Add World Instance flag
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index e8c0c853eb52d1473c20231660355f77b1f7e016..02e524f718566a13880c9417518ebaeca816a8fc 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2591,6 +2591,11 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/
public void setAutoSave(boolean value);
+ // Slice start
+ public boolean isInstance();
+ public void setInstance(boolean value);
+ // Slice end
+
/**
* Sets the Difficulty of the world.
*

View File

@@ -1,133 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:52:37 -0500
Subject: [PATCH] Add player data saving events
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..ae0132d9c7ae17b478d1d504961e1fd6b479f6d0
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadDataEvent.java
@@ -0,0 +1,63 @@
+package com.destroystokyo.paper.event.player;
+
+import com.google.gson.JsonObject;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.UUID;
+
+/**
+ * Calls an event in which playerdata can be provided. If null, will load from disk, otherwise will use provided data
+ */
+public class PlayerLoadDataEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ private final UUID playerId;
+ private Object playerData;
+ private JsonObject statistics;
+
+ public PlayerLoadDataEvent(@NotNull UUID playerId) {
+ super();
+ this.playerId = playerId;
+ }
+
+ /**
+ * Gets the player's unique ID.
+ *
+ * @return The unique ID
+ */
+ @NotNull
+ public UUID getUniqueId() {
+ return playerId;
+ }
+
+ @Nullable
+ public Object getPlayerData() {
+ return playerData;
+ }
+
+ public void setPlayerData(@NotNull Object playerData) {
+ this.playerData = playerData;
+ }
+
+ @Nullable
+ public JsonObject getStatistics() {
+ return statistics;
+ }
+
+ public void setStatistics(@NotNull JsonObject statistics) {
+ this.statistics = statistics;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..c706201394d89f4a6f795ebbbac3d1041f395104
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerSaveDataEvent.java
@@ -0,0 +1,52 @@
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Calls whenever playerdata is attempted to be saved. This is fired even if SpigotConfig.disablePlayerDataSaving is true
+ */
+public class PlayerSaveDataEvent extends Event implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Player player;
+ private boolean cancel;
+
+ public PlayerSaveDataEvent(@NotNull Player player) {
+ super();
+ this.player = player;
+ }
+
+ /**
+ * Gets the player
+ *
+ * @return The player
+ */
+ @NotNull
+ public Player getPlayer() {
+ return player;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}

View File

@@ -1,65 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 11:00:39 -0500
Subject: [PATCH] Add PlayerGetRespawnLocationEvent
diff --git a/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java b/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7eca4d6929fc7a75974d182c1ea692d3823a19c0
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerGetRespawnLocationEvent.java
@@ -0,0 +1,53 @@
+package org.bukkit.event.player;
+
+import org.apache.commons.lang3.Validate;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a respawn event tries to determine the location of a respawn
+ */
+public class PlayerGetRespawnLocationEvent extends PlayerEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private Location respawnLocation;
+
+ public PlayerGetRespawnLocationEvent(@NotNull final Player respawnPlayer) {
+ super(respawnPlayer);
+ }
+
+ /**
+ * Gets the current respawn location
+ *
+ * @return Location current respawn location
+ */
+ @Nullable
+ public Location getRespawnLocation() {
+ return this.respawnLocation;
+ }
+
+ /**
+ * Sets the new respawn location
+ *
+ * @param respawnLocation new location for the respawn
+ */
+ public void setRespawnLocation(@NotNull Location respawnLocation) {
+ Validate.notNull(respawnLocation, "Respawn location can not be null");
+ Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
+
+ this.respawnLocation = respawnLocation;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,35 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:40:03 -0500
Subject: [PATCH] Set multiple Team settings at once
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 06a5d3177ca7ab90c3fd9d2053b2ec5e887c7c62..31e2756c134462debfcfa768d2d0ccb988046d72 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -532,6 +532,24 @@ public interface Team {
boolean hasEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException;
// Paper end
+ //Slice start
+ /**
+ * Fully set all team options, combining all 5 options into one packet send, rather than one packet sent
+ * for every single option change.
+ * @param displayName New display name
+ * @param prefix New prefix
+ * @param suffix New suffix
+ * @param color new color
+ * @param options A Paired list of options
+ * @throws IllegalStateException
+ */
+ void teamOptions(net.kyori.adventure.text.Component displayName,
+ net.kyori.adventure.text.Component prefix,
+ net.kyori.adventure.text.Component suffix,
+ net.kyori.adventure.text.format.NamedTextColor color,
+ java.util.List<org.apache.commons.lang3.tuple.Pair<Option, OptionStatus>> options) throws IllegalStateException;
+ //Slice end
+
/**
* Represents an option which may be applied to this team.
*/

View File

@@ -1,30 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:58:21 -0500
Subject: [PATCH] Smooth Teleports
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 1e27b9de47f111b9c000243214e22890e323f7fc..39c65831f38b3992c52f35abcc4aab1d2e09473c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2763,6 +2763,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
String getClientBrandName();
// Paper end
+ /**
+ * This abuses some of how Minecraft works and allows teleporting a player to another world without
+ * triggering typical respawn packets. All of natural state of chunk resends, entity adds/removes, etc still
+ * happen but the visual "refresh" of a world change is hidden. Depending on the destination location/world,
+ * this can act as a "smooth teleport" to a world if the new world is very similar looking to the old one.
+ *
+ * @param location New location to teleport this Player to
+ */
+ // Slice start
+ @org.jetbrains.annotations.ApiStatus.Experimental
+ void teleportWithoutRespawn(Location location);
+ // Slice end
+
// Paper start - Teleport API
/**
* Sets the player's rotation.

View File

@@ -1,149 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:02:12 -0600
Subject: [PATCH] Equipment Packet Caching
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 97336be470a9d545d93f78e683a793f328013ad8..d57ff4b918e3c6e97b2d0664394c7faf46aa3b00 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1059,4 +1059,11 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
*/
void damageItemStack(org.bukkit.inventory.@NotNull EquipmentSlot slot, int amount);
// Paper end
+
+ // Slice start
+ /**
+ * @param p The player to send this entity's equipment packet to
+ */
+ void sendEquipment(Player p);
+ // Slice end
}
diff --git a/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java b/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c329ca3c22d1fd712041334c5c1e7bd7e7201ac
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EntityEquipmentItemLookup.java
@@ -0,0 +1,54 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.event.HandlerList;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when requesting a cached equipment item lookup
+ */
+public class EntityEquipmentItemLookup extends EntityEvent {
+ private static final HandlerList handlers = new HandlerList();
+ private final String tag;
+ private final EquipmentSlot equipmentSlot;
+ private ItemStack itemStack;
+
+ public EntityEquipmentItemLookup(@NotNull final Entity entity, @NotNull String tag, @NotNull EquipmentSlot slot, @NotNull final ItemStack itemStack) {
+ super(entity);
+ this.tag = tag;
+ this.equipmentSlot = slot;
+ this.itemStack = itemStack;
+ }
+
+ @NotNull
+ public ItemStack getItemStack() {
+ return itemStack;
+ }
+
+ public void setItemStack(ItemStack itemStack) {
+ this.itemStack = itemStack;
+ }
+
+ @NotNull
+ public EquipmentSlot getEquipmentSlot() {
+ return equipmentSlot;
+ }
+
+ @NotNull
+ public String getTag() {
+ return tag;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java b/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..513d62342d8e29e8d3c92fe932d0d77f659cf2f1
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/PlayerReceiveEquipmentEvent.java
@@ -0,0 +1,61 @@
+package org.bukkit.event.player;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Called when a player is about to receive an equipment packet about another player
+ */
+public class PlayerReceiveEquipmentEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final Entity tracked;
+ private boolean cancel;
+ private String tag;
+
+ public PlayerReceiveEquipmentEvent(@NotNull final Player player, @NotNull final Entity tracked) {
+ super(player);
+ this.tracked = tracked;
+ }
+
+ /**
+ * Gets the tracked entity
+ *
+ * @return Entity the player is now tracking
+ */
+ @NotNull
+ public Entity getTracked() {
+ return tracked;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}

View File

@@ -1,21 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:03:20 -0600
Subject: [PATCH] AntiXray Bypass
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 39c65831f38b3992c52f35abcc4aab1d2e09473c..8c101c66b2c8d7044d29474e37c10838ee3e5d0c 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2543,6 +2543,10 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/
boolean hasResourcePack();
+ // Slice start
+ void toggleAntiXrayBypass(boolean bypass);
+ // Slice end
+
/**
* Gets a copy of this players profile
* @return The players profile object

View File

@@ -1,95 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:06:32 -0600
Subject: [PATCH] PlayerPreChunkLoadEvent
diff --git a/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java b/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..b5cc9538a70c7ce0b494d4878d51b52134c2fd75
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/packet/PlayerPreChunkLoadEvent.java
@@ -0,0 +1,69 @@
+package io.papermc.paper.event.packet;
+
+import org.bukkit.Chunk;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Is called when a {@link Player} is about to receive a {@link Chunk}
+ * <p>
+ * Can be cancelled, but only use if you really really mean it.
+ */
+public class PlayerPreChunkLoadEvent extends Event implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+ private final World world;
+ private final int chunkX;
+ private final int chunkZ;
+ private final Player player;
+ private boolean cancel;
+
+ public PlayerPreChunkLoadEvent(World world, int chunkX, int chunkZ, @NotNull Player player) {
+ this.world = world;
+ this.chunkX = chunkX;
+ this.chunkZ = chunkZ;
+ this.player = player;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+ public int getChunkX() {
+ return chunkX;
+ }
+
+ public int getChunkZ() {
+ return chunkZ;
+ }
+
+ @NotNull
+ public Player getPlayer() {
+ return player;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index adb5fcbacf5fa284e4c6efc1dcc0f30f3932761c..27f6db119f0c720e191ba7f9b64d8aded972a8f9 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -515,6 +515,8 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
//@Deprecated // Paper
public boolean refreshChunk(int x, int z);
+ it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunks(Player p); // Slice
+
/**
* Gets whether the chunk at the specified chunk coordinates is force
* loaded.

View File

@@ -1,177 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tom <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:20:02 -0500
Subject: [PATCH] Set BlockData without light updates
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
index 0d3587e2d454fb0994ecff930b5e496a3999746a..57896cf095bad0367f65a514ac8befa53f4863a4 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
@@ -234,7 +234,7 @@ public class WorldGenRegion implements WorldGenLevel {
Block.dropResources(iblockdata, this.level, pos, tileentity, breakingEntity, ItemStack.EMPTY);
}
- return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth);
+ return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth, true); // Slice
}
}
@@ -309,7 +309,7 @@ public class WorldGenRegion implements WorldGenLevel {
}
@Override
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) { // Slice
if (!this.ensureCanWrite(pos)) {
return false;
} else {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 596fb8ee21ba8450db13a11890d241ef3974d81d..2fff811d725dedaac2085bb3eaedea8bd7620c56 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -509,12 +509,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
@Override
- public final boolean setBlock(BlockPos pos, BlockState state, int flags) { // Paper - final for inline
- return this.setBlock(pos, state, flags, 512);
+ public final boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) { // Paper - final for inline
+ return this.setBlock(pos, state, flags, 512, checkLight);
}
@Override
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) {
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {
// Paper start
@@ -561,7 +561,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} else {
BlockState iblockdata2 = this.getBlockState(pos);
- if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
+ if (checkLight && (flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
this.getProfiler().push("queueCheckLight");
this.getChunkSource().getLightEngine().checkBlock(pos);
this.getProfiler().pop();
@@ -709,7 +709,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY);
}
- boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth);
+ boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth, true);
if (flag1) {
this.gameEvent(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(breakingEntity, iblockdata));
diff --git a/src/main/java/net/minecraft/world/level/LevelWriter.java b/src/main/java/net/minecraft/world/level/LevelWriter.java
index 134e5ec79bf2dddd4e31930f8a7cb2c02fa29518..fd72d278a2719911a46b6bc9e7da2dc24bbe681e 100644
--- a/src/main/java/net/minecraft/world/level/LevelWriter.java
+++ b/src/main/java/net/minecraft/world/level/LevelWriter.java
@@ -7,10 +7,14 @@ import net.minecraft.world.level.block.state.BlockState;
public interface LevelWriter {
- boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth);
+ boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight);
default boolean setBlock(BlockPos pos, BlockState state, int flags) {
- return this.setBlock(pos, state, flags, 512);
+ return this.setBlock(pos, state, flags, 512, true);
+ }
+
+ default boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) {
+ return this.setBlock(pos, state, flags, 512, checkLight);
}
boolean removeBlock(BlockPos pos, boolean move);
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
index 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..f85777b5d4003a9fcc6f19976ea6ef23a8674c68 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -198,7 +198,7 @@ public class Block extends BlockBehaviour implements ItemLike {
world.destroyBlock(pos, (flags & 32) == 0, (Entity) null, maxUpdateDepth);
}
} else {
- world.setBlock(pos, newState, flags & -33, maxUpdateDepth);
+ world.setBlock(pos, newState, flags & -33, maxUpdateDepth, true); // Slice
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
index 32865ef1903a5e499b27c82fd5be90aa084744cb..0c1349c6070cf2288b40ab1f9bf6894f4d2d377a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -277,7 +277,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
BlockPos pos = new BlockPos(x, y, z);
net.minecraft.world.level.block.state.BlockState old = this.getHandle().getBlockState(pos);
- CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true);
+ CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true, true);
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 0d47460494135d4ec4c95260de033e054c2f0404..4d49cc4ceba781bc24ac9b4229483625a996839d 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -187,15 +187,20 @@ public class CraftBlock implements Block {
@Override
public void setBlockData(BlockData data, boolean applyPhysics) {
+ setBlockData(data, applyPhysics, true);
+ }
+
+ @Override
+ public void setBlockData(BlockData data, boolean applyPhysics, boolean checkLight) {
Preconditions.checkArgument(data != null, "BlockData cannot be null");
- this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
+ this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics, checkLight);
}
- boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics) {
- return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics);
+ boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics, boolean checkLight) {
+ return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics, checkLight);
}
- public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
+ public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics, boolean checkLight) {
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
// SPIGOT-4612: faster - just clear tile
@@ -209,7 +214,7 @@ public class CraftBlock implements Block {
if (applyPhysics) {
return world.setBlock(position, blockData, 3);
} else {
- boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
+ boolean success = world.setBlock(position, blockData, 2 | 16 | 1024, checkLight); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
if (success && world instanceof net.minecraft.world.level.Level) {
world.getMinecraftWorld().sendBlockUpdated(
position,
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
index a8ab1d3ee81664193be39d2735d6495136e0e310..fd4f00fa38b2d90e13937f114d96ea37bbc6dcdb 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
@@ -213,7 +213,7 @@ public class CraftBlockState implements BlockState {
}
net.minecraft.world.level.block.state.BlockState newBlock = this.data;
- block.setTypeAndData(newBlock, applyPhysics);
+ block.setTypeAndData(newBlock, applyPhysics, true);
if (access instanceof net.minecraft.world.level.Level) {
this.world.getHandle().sendBlockUpdated(
position,
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
index cd0dc080fbd8c5b1509d67e2b60264393b2b7dbb..8195cace753c6d044a128f768459303bc2f97588 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
@@ -241,7 +241,7 @@ public class DummyGeneratorAccess implements WorldGenLevel {
}
@Override
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) {
return false;
}

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:23:13 -0500
Subject: [PATCH] Ignore durability change equipment updates
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 11d7c42d65b91bf57b7bba7812aa17e60e018c67..be20f0971d34804b95f939896594f747497fde53 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3086,7 +3086,7 @@ public abstract class LivingEntity extends Entity {
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
- if (!ItemStack.matches(itemstack1, itemstack)) {
+ if (!ItemStack.isSameIgnoreDurability(itemstack1, itemstack)) { // Slice
// Paper start - PlayerArmorChangeEvent
if (this instanceof ServerPlayer && enumitemslot.getType() == EquipmentSlot.Type.ARMOR) {
final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack);

View File

@@ -1,43 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:28:00 -0500
Subject: [PATCH] Alllow opening covered chests
diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
index c6b57d45383441aa35510e759ce3cb82bc98f305..0f6dc8ab64f2422f636c2792be06f31bafefe3f8 100644
--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
@@ -355,9 +355,10 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements
}
private static boolean isBlockedChestByBlock(BlockGetter world, BlockPos pos) {
- BlockPos blockposition1 = pos.above();
-
- return world.getBlockState(blockposition1).isRedstoneConductor(world, blockposition1);
+ return false;
+// BlockPos blockposition1 = pos.above();
+//
+// return world.getBlockState(blockposition1).isRedstoneConductor(world, blockposition1);
}
private static boolean isCatSittingOnChest(LevelAccessor world, BlockPos pos) {
diff --git a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
index 7385e91f32f070e86a4e0fd3d214f55d832c7979..4911b099f865b9202286f51087e5c00ffeaa95a5 100644
--- a/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/EnderChestBlock.java
@@ -76,10 +76,10 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
PlayerEnderChestContainer playerEnderChestContainer = player.getEnderChestInventory();
BlockEntity blockEntity = world.getBlockEntity(pos);
if (playerEnderChestContainer != null && blockEntity instanceof EnderChestBlockEntity) {
- BlockPos blockPos = pos.above();
- if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) {
- return InteractionResult.sidedSuccess(world.isClientSide);
- } else if (world.isClientSide) {
+// BlockPos blockPos = pos.above();
+// if (world.getBlockState(blockPos).isRedstoneConductor(world, blockPos)) {
+// return InteractionResult.sidedSuccess(world.isClientSide);
+ if (world.isClientSide) {
return InteractionResult.SUCCESS;
} else {
EnderChestBlockEntity enderChestBlockEntity = (EnderChestBlockEntity)blockEntity;

View File

@@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 08:28:40 -0500
Subject: [PATCH] Don't send fire packets if player has FR
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index f925a8d550ecbf2044a37bfe58b30d6578c5f6af..7e31ac6b1097fc5d4faac98d0f1b5673da4e6694 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -844,7 +844,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.checkOutOfWorld();
if (!this.level.isClientSide) {
- this.setSharedFlagOnFire(this.remainingFireTicks > 0);
+ if (this instanceof net.minecraft.world.entity.LivingEntity livingEntity) {
+ this.setSharedFlagOnFire(this.remainingFireTicks > 0 && !livingEntity.hasEffect(net.minecraft.world.effect.MobEffects.FIRE_RESISTANCE));
+ } else {
+ this.setSharedFlagOnFire(this.remainingFireTicks > 0);
+ }
}
this.firstTick = false;

View File

@@ -1,137 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 09:54:06 -0500
Subject: [PATCH] Add BlockDestroyedByNeighborEvent
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 0a5f8d990cce5df339fd9b2b0fcb291a20ddad41..d074483088ab4d2377e1bf249ca8cb59f1c45a1d 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -410,6 +410,7 @@ public class ServerPlayerGameMode {
org.bukkit.block.BlockState state = bblock.getState();
level.captureDrops = new ArrayList<>();
// CraftBukkit end
+ level.pendingPlayerBlockEvents.put(pos, new Level.PendingBlockEvent(pos, this.player)); // Paper
block.playerWillDestroy(this.level, pos, iblockdata, this.player);
boolean flag = this.level.removeBlock(pos, false);
@@ -438,6 +439,7 @@ public class ServerPlayerGameMode {
// CraftBukkit start
java.util.List<net.minecraft.world.entity.item.ItemEntity> itemsToDrop = level.captureDrops; // Paper - store current list
level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff
+ level.pendingPlayerBlockEvents.remove(pos); // Paper
if (event.isDropItems()) {
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index c18a0bc94d0210396046f4475e49a739088593f3..03f057134831bd119bb8dd820d4a0868b8f90b31 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -345,6 +345,7 @@ public final class ItemStack {
}
}
Item item = this.getItem();
+ if (entityhuman != null) world.pendingPlayerBlockEvents.put(blockposition, new Level.PendingBlockEvent(blockposition, entityhuman)); // Paper
InteractionResult enuminteractionresult = item.useOn(itemactioncontext);
CompoundTag newData = this.getTagClone();
int newCount = this.getCount();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 2fff811d725dedaac2085bb3eaedea8bd7620c56..fac83e6a3c6120a8e8768e363fc82083e4e53265 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -182,6 +182,27 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
+ // Paper start - Holder class used to track what Player is responsible the last block event
+ public static class PendingBlockEvent {
+
+ public final BlockPos block;
+ public final Player player;
+ public @Nullable BlockPos sourceBlock;
+
+ public PendingBlockEvent(BlockPos block, Player player) {
+ this(block, player, null);
+ }
+
+ public PendingBlockEvent(BlockPos block, Player player, @Nullable BlockPos sourceBlock) {
+ this.block = block;
+ this.player = player;
+ this.sourceBlock = sourceBlock;
+ }
+
+ }
+ public final Map<BlockPos, PendingBlockEvent> pendingPlayerBlockEvents = new HashMap<>();
+ // Paper end
+
// Paper start - fix and optimise world upgrading
// copied from below
public static ResourceKey<DimensionType> getDimensionKey(DimensionType manager) {
@@ -663,6 +684,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (!this.preventPoiUpdated) {
this.onBlockStateChange(blockposition, iblockdata1, iblockdata2);
}
+ pendingPlayerBlockEvents.remove(blockposition); // Paper
// CraftBukkit end
}
}
@@ -684,6 +706,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (iblockdata.isAir()) {
return false;
} else {
+ // Paper start
+ PendingBlockEvent blockEvent = pendingPlayerBlockEvents.get(pos);
+ if (blockEvent != null && blockEvent.sourceBlock != null) {
+ io.papermc.paper.event.block.BlockDestroyedByNeighborEvent event =
+ new io.papermc.paper.event.block.BlockDestroyedByNeighborEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos),
+ (org.bukkit.entity.Player) blockEvent.player.getBukkitEntity(),
+ org.bukkit.craftbukkit.block.CraftBlock.at(this, blockEvent.sourceBlock));
+ event.callEvent();
+ }
+ // Paper end
+
FluidState fluid = this.getFluidState(pos);
// Paper start - while the above setAir method is named same and looks very similar
// they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent,
diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
index fa97966d39f01301a8ba976c02dc697e0a74bfb1..3f0cbdb4294f3fc1b953d7baa7903d2e5471b337 100644
--- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
@@ -103,6 +103,15 @@ public class DoublePlantBlock extends BushBlock {
BlockPos blockposition1 = pos.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
+ Level.PendingBlockEvent blockEvent = world.pendingPlayerBlockEvents.remove(pos);
+ if (blockEvent != null) {
+ io.papermc.paper.event.block.BlockDestroyedByNeighborEvent event =
+ new io.papermc.paper.event.block.BlockDestroyedByNeighborEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition1),
+ (org.bukkit.entity.Player) blockEvent.player.getBukkitEntity(),
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, pos));
+ if (!event.callEvent()) return;
+ }
+
if (iblockdata1.is(state.getBlock()) && iblockdata1.getValue(DoublePlantBlock.HALF) == DoubleBlockHalf.LOWER) {
BlockState iblockdata2 = iblockdata1.hasProperty(BlockStateProperties.WATERLOGGED) && (Boolean) iblockdata1.getValue(BlockStateProperties.WATERLOGGED) ? Blocks.WATER.defaultBlockState() : Blocks.AIR.defaultBlockState();
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index b86c17b5572f8f74bfefd0f3c6f9d25187574392..473161ff4ba0939d69d212eb032ceb630fe5d19e 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -989,6 +989,16 @@ public abstract class BlockBehaviour {
Direction enumdirection = aenumdirection[l];
blockposition_mutableblockposition.setWithOffset(pos, enumdirection);
+ // Paper start - Propagate the PendingBlockEvent from the current blockPos to the next block
+ // if it will break (!canSurvive)
+ if (this.getMaterial() == Material.AIR && !world.getBlockState(blockposition_mutableblockposition).canSurvive(world, blockposition_mutableblockposition)) {
+ Level.PendingBlockEvent blockEvent = ((Level) world).pendingPlayerBlockEvents.get(pos);
+ if (blockEvent != null) {
+ BlockPos blockPosCopy = blockposition_mutableblockposition.immutable();
+ ((Level) world).pendingPlayerBlockEvents.put(blockPosCopy, new Level.PendingBlockEvent(blockPosCopy, blockEvent.player, pos));
+ }
+ }
+ // Paper end
world.neighborShapeChanged(enumdirection.getOpposite(), this.asState(), blockposition_mutableblockposition, pos, flags, maxUpdateDepth);
}

View File

@@ -1,38 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:40:48 -0500
Subject: [PATCH] Add provided Material to getDrops
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 4d49cc4ceba781bc24ac9b4229483625a996839d..1d22923bfd3be24a6f637114613065ae6afeba96 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -592,7 +592,18 @@ public class CraftBlock implements Block {
@Override
public Collection<ItemStack> getDrops(ItemStack item, Entity entity) {
- net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
+ return getDrops(null, item, entity); // Slice start
+ }
+
+ @Override
+ public Collection<ItemStack> getDrops(Material blockType, ItemStack item, Entity entity) {
+ net.minecraft.world.level.block.state.BlockState iblockdata;
+ if (blockType == null) {
+ iblockdata = this.getNMS();
+ } else {
+ iblockdata = ((CraftBlockData) blockType.createBlockData()).getState();
+ }
+
net.minecraft.world.item.ItemStack nms = CraftItemStack.asNMSCopy(item);
// Modelled off EntityHuman#hasBlock
@@ -603,6 +614,7 @@ public class CraftBlock implements Block {
return Collections.emptyList();
}
}
+ // Slice end
@Override
public boolean isPreferredTool(ItemStack item) {

View File

@@ -1,20 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:41:43 -0500
Subject: [PATCH] Add Player to SpongeAbsorbEvent
diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
index 7304b2659eb45bc4bc9fa7c43e6ca07221d0fc73..63e385993022b6e708e981982c18060273d3e019 100644
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
@@ -109,7 +109,8 @@ public class SpongeBlock extends Block {
if (!blocks.isEmpty()) {
final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
- SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List<org.bukkit.block.BlockState>) (List) blocks);
+ Level.PendingBlockEvent blockEvent = world.pendingPlayerBlockEvents.remove(pos); // Paper
+ SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, blockEvent != null ? (org.bukkit.entity.Player) blockEvent.player.getBukkitEntity() : null, (List<org.bukkit.block.BlockState>) (List) blocks); // Paper
world.getCraftServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@@ -1,41 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:45:51 -0500
Subject: [PATCH] Add World Instance flag
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a8cdb261c0f8c9a377bb4a6d39afbe5ef6f0d146..571753395ecfe82e3c95ad7f322981991ab0c94d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -219,6 +219,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public final UUID uuid;
public boolean hasPhysicsEvent = true; // Paper
public boolean hasEntityMoveEvent = false; // Paper
+ public boolean instance; // Slice
private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current)
public static Throwable getAddToWorldStackTrace(Entity entity) {
final Throwable thr = new Throwable(entity + " Added to world at " + new java.util.Date());
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 55d83a9a691d11c9408d2c3260c3e77dfb51b97e..6d92d1e1301555dd77968e9f1d7347497200dd63 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1267,6 +1267,18 @@ public class CraftWorld extends CraftRegionAccessor implements World {
world.noSave = !value;
}
+ // Slice start
+ @Override
+ public boolean isInstance() {
+ return world.instance;
+ }
+
+ @Override
+ public void setInstance(boolean value) {
+ world.instance = value;
+ }
+ // Slice end
+
@Override
public void setDifficulty(Difficulty difficulty) {
this.getHandle().getServer().setDifficulty(this.getHandle(), net.minecraft.world.Difficulty.byId(difficulty.getValue()), true); // Paper - don't skip other difficulty-changing logic

View File

@@ -1,195 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:48:03 -0500
Subject: [PATCH] Packet obfuscation and reduction
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java
index bf838c097aeb79fbe82c0b6cdf3315acf03474cd..88c488cc9bcbfdec50654a8d67ebbd65b325cedf 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java
@@ -27,6 +27,13 @@ public class ClientboundSetEntityDataPacket implements Packet<ClientGamePacketLi
}
+ // Slice start
+ public ClientboundSetEntityDataPacket(int id, List<SynchedEntityData.DataItem<?>> packedItems) {
+ this.id = id;
+ this.packedItems = packedItems;
+ }
+ // Slice end
+
public ClientboundSetEntityDataPacket(FriendlyByteBuf buf) {
this.id = buf.readVarInt();
this.packedItems = SynchedEntityData.unpack(buf);
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
index a376fc453986b66560f57076f0a72dcae9d427c2..2f28c2a8f99732c1791283429730b5d2fd3c1d4f 100644
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
@@ -137,6 +137,11 @@ public class SynchedEntityData {
}
public <T> void set(EntityDataAccessor<T> key, T value) {
+ //Slice start
+ set(key, value, null);
+ }
+
+ public <T> void set(EntityDataAccessor<T> key, T value, @Nullable T foreignValue) { // Slice end
SynchedEntityData.DataItem<T> datawatcher_item = this.getItem(key);
if (ObjectUtils.notEqual(value, datawatcher_item.getValue())) {
@@ -146,6 +151,11 @@ public class SynchedEntityData {
this.isDirty = true;
}
+ // Slice start
+ if (foreignValue != null && ObjectUtils.notEqual(foreignValue, datawatcher_item.getForeignValue())) {
+ datawatcher_item.setForeignValue(foreignValue);
+ }
+ // Slice end
}
// CraftBukkit start - add method from above
@@ -201,6 +211,28 @@ public class SynchedEntityData {
return list;
}
+ // Slice start
+ @Nullable
+ public List<SynchedEntityData.DataItem<?>> packForeignDirty(List<DataItem<?>> unpackedData) {
+ List<SynchedEntityData.DataItem<?>> list = null;
+
+ for (DataItem<?> dataItem : unpackedData) {
+ DataItem<?> item = itemsById.get(dataItem.accessor.getId());
+ if (item.isDirty(true)) {
+ item.setForeignDirty(false);
+
+ if (list == null) {
+ list = Lists.newArrayList();
+ }
+
+ list.add(item.copy(true));
+ }
+ }
+
+ return list;
+ }
+ // Slice end
+
@Nullable
public List<SynchedEntityData.DataItem<?>> getAll() {
List<SynchedEntityData.DataItem<?>> list = null;
@@ -314,11 +346,14 @@ public class SynchedEntityData {
final EntityDataAccessor<T> accessor;
T value;
private boolean dirty;
+ @Nullable T foreignValue = null; // Slice
+ private boolean foreignDirty; // Slice
public DataItem(EntityDataAccessor<T> data, T value) {
this.accessor = data;
this.value = value;
this.dirty = true;
+ this.foreignDirty = true; // Slice
}
public EntityDataAccessor<T> getAccessor() {
@@ -344,5 +379,34 @@ public class SynchedEntityData {
public SynchedEntityData.DataItem<T> copy() {
return new SynchedEntityData.DataItem<>(this.accessor, this.accessor.getSerializer().copy(this.value));
}
+
+ // Slice start
+ public void setForeignValue(T foreignValue) {
+ this.foreignValue = foreignValue;
+ this.foreignDirty = true;
+ }
+
+ public @Nullable T getForeignValue() {
+ return foreignValue;
+ }
+
+ public boolean isDirty(boolean foreign) {
+ if (foreign) {
+ //There must be a foreign value in order for this to be dirty, otherwise we consider this a normal
+ //value and check the normal dirty flag.
+ return foreignValue == null || this.foreignDirty;
+ }
+
+ return this.dirty;
+ }
+
+ public void setForeignDirty(boolean dirty) {
+ this.foreignDirty = dirty;
+ }
+
+ public SynchedEntityData.DataItem<T> copy(boolean foreign) {
+ return new SynchedEntityData.DataItem<>(this.accessor, this.accessor.getSerializer().copy((foreign && this.foreignValue != null ? this.foreignValue : this.value)));
+ }
+ // Slice end
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 2358bb1788cfb902bac9b3b7588954af2d2cd823..8b30e408d12ccabb66f94829879781e88023f271 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -361,7 +361,19 @@ public class ServerEntity {
SynchedEntityData datawatcher = this.entity.getEntityData();
if (datawatcher.isDirty()) {
- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false));
+ // Slice start
+ ClientboundSetEntityDataPacket dataPacket = new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false);
+ if (this.entity instanceof ServerPlayer serverPlayer) {
+ serverPlayer.connection.send(dataPacket);
+ }
+
+ //Get the packedData that the original packet has, and then determine if any of those are changed in
+ //the foreign version. If null, nothing to notify foreign trackers about.
+ List<SynchedEntityData.DataItem<?>> dirtyItems = datawatcher.packForeignDirty(dataPacket.getUnpackedData());
+ if (dirtyItems != null) {
+ this.broadcast(new ClientboundSetEntityDataPacket(this.entity.getId(), dirtyItems));
+ }
+ // Slice end
}
if (this.entity instanceof LivingEntity) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a6c58a4cd3e9b0621fa1691d585c284e72091873..e8ca5bed288ee13b68de2e5d01fbccfe9cac5b1d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3100,7 +3100,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return;
}
- this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount());
+ this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount(), getMaxAirSupply()); // Slice
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 08732b3a77ad0541b3ca57b4478e13a337e31439..a03477da71266e61dc219b5da9a15c48f32b508a 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -641,7 +641,7 @@ public abstract class Player extends LivingEntity {
public void increaseScore(int score) {
int j = this.getScore();
- this.entityData.set(Player.DATA_SCORE_ID, j + score);
+ this.entityData.set(Player.DATA_SCORE_ID, j + score, 0); // Slice
}
public void startAutoSpinAttack(int riptideTicks) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 66830ccee464083879f79db4111e08fecee417ec..46c3f5327adb2324a77c3576958cc91866960e7c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2351,7 +2351,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.sendHealthUpdate();
}
}
- this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_HEALTH_ID, (float) this.getScaledHealth());
+ this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_HEALTH_ID, (float) this.getScaledHealth(), isDead() ? 0f : 20f); // Slice
this.getHandle().maxHealthCache = getMaxHealth();
}

View File

@@ -1,121 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 10:52:36 -0500
Subject: [PATCH] Add player data saving events
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index d074483088ab4d2377e1bf249ca8cb59f1c45a1d..83886825ffa726e7e58f828d947eca7cce081eb4 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -590,6 +590,8 @@ public class ServerPlayerGameMode {
enuminteractionresult1 = stack.useOn(itemactioncontext, hand);
}
+ world.pendingPlayerBlockEvents.remove(blockposition); // Paper
+
if (enuminteractionresult1.consumesAction()) {
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(player, blockposition, itemstack1);
}
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
index c59f98ca3adfdd90cdc5999aeadbb0834efedc0f..6e819bd376eb9edee6bf8bd8c08a755599f1514a 100644
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
@@ -201,7 +201,12 @@ public class ServerStatsCounter extends StatsCounter {
return nbttagcompound;
}
- protected String toJson() {
+ // Slice start - OBFHELPER
+ public String toJson() {
+ return serialize().toString();
+ }
+
+ public JsonObject serialize() { // Slice end
Map<StatType<?>, JsonObject> map = Maps.newHashMap();
ObjectIterator objectiterator = this.stats.object2IntEntrySet().iterator();
@@ -227,7 +232,7 @@ public class ServerStatsCounter extends StatsCounter {
jsonobject1.add("stats", jsonobject);
jsonobject1.addProperty("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
- return jsonobject1.toString();
+ return jsonobject1; // Slice
}
private static <T> ResourceLocation getKey(Stat<T> stat) {
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
index 601f8099f74e81c17600566b3c9b7a6dd39c9bcb..cde84f45b67b88ecc410cdff924170b5b5366823 100644
--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
@@ -33,6 +33,7 @@ public class PlayerDataStorage {
public void save(Player player) {
if (org.spigotmc.SpigotConfig.disablePlayerDataSaving) return; // Spigot
+ if (!new com.destroystokyo.paper.event.player.PlayerSaveDataEvent((org.bukkit.entity.Player) player.getBukkitEntity()).callEvent()) return; // Slice
try {
CompoundTag nbttagcompound = player.saveWithoutId(new CompoundTag());
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", this.playerDir);
@@ -52,32 +53,40 @@ public class PlayerDataStorage {
public CompoundTag load(Player player) {
CompoundTag nbttagcompound = null;
- try {
- File file = new File(this.playerDir, player.getStringUUID() + ".dat");
- // Spigot Start
- boolean usingWrongFile = false;
- if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first
- {
- file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + player.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
- if ( file.exists() )
+ // Slice start - If event supplies playerdata, use it. Otherwise just load from disk as usual
+ com.destroystokyo.paper.event.player.PlayerLoadDataEvent event = new com.destroystokyo.paper.event.player.PlayerLoadDataEvent(player.getUUID());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+
+ Object playerData = event.getPlayerData();
+ if (playerData != null) {
+ nbttagcompound = (CompoundTag) playerData;
+ } else {
+ try {
+ File file = new File(this.playerDir, player.getStringUUID() + ".dat");
+ // Spigot Start
+ boolean usingWrongFile = false;
+ if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) // Paper - Check online mode first
{
- usingWrongFile = true;
- org.bukkit.Bukkit.getServer().getLogger().warning( "Using offline mode UUID file for player " + player.getScoreboardName() + " as it is the only copy we can find." );
+ file = new File(this.playerDir, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getScoreboardName()).getBytes("UTF-8")).toString() + ".dat");
+ if (file.exists()) {
+ usingWrongFile = true;
+ org.bukkit.Bukkit.getServer().getLogger().warning("Using offline mode UUID file for player " + player.getScoreboardName() + " as it is the only copy we can find.");
+ }
}
- }
- // Spigot End
+ // Spigot End
- if (file.exists() && file.isFile()) {
- nbttagcompound = NbtIo.readCompressed(file);
- }
- // Spigot Start
- if ( usingWrongFile )
- {
- file.renameTo( new File( file.getPath() + ".offline-read" ) );
+ if (file.exists() && file.isFile()) {
+ nbttagcompound = NbtIo.readCompressed(file);
+ }
+ // Spigot Start
+ if (usingWrongFile) {
+ file.renameTo(new File(file.getPath() + ".offline-read"));
+ }
+ // Spigot End
+ } catch (Exception exception) {
+ PlayerDataStorage.LOGGER.warn("Failed to load player data for {}", player.getName().getString());
}
- // Spigot End
- } catch (Exception exception) {
- PlayerDataStorage.LOGGER.warn("Failed to load player data for {}", player.getName().getString());
+ // Slice end
}
if (nbttagcompound != null) {

View File

@@ -1,102 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 11:00:39 -0500
Subject: [PATCH] Add PlayerGetRespawnLocationEvent
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 3be9352ae9b0b84acf07064b45562ceffd30391b..6f0efd3459da45e4aa3a59e8b647725b779cdf51 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -886,49 +886,57 @@ public abstract class PlayerList {
// CraftBukkit start - fire PlayerRespawnEvent
if (location == null) {
- // boolean isBedSpawn = false; // Paper - moved up
- ServerLevel worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension());
- if (worldserver1 != null) {
- Optional optional;
+ // Slice start
+ Player respawnPlayer = entityplayer1.getBukkitEntity();
+ org.bukkit.event.player.PlayerGetRespawnLocationEvent preRespawnEvent = new org.bukkit.event.player.PlayerGetRespawnLocationEvent(respawnPlayer);
+ preRespawnEvent.callEvent();
+ location = preRespawnEvent.getRespawnLocation();
- if (blockposition != null) {
- optional = net.minecraft.world.entity.player.Player.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, true); // Paper - Fix SPIGOT-5989
- } else {
- optional = Optional.empty();
- }
+ if (location == null) {
+ // Slice end
+ // boolean isBedSpawn = false; // Paper - moved up
+ ServerLevel worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension());
+ if (worldserver1 != null) {
+ Optional optional;
+
+ if (blockposition != null) {
+ optional = net.minecraft.world.entity.player.Player.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, true); // Paper - Fix SPIGOT-5989
+ } else {
+ optional = Optional.empty();
+ }
- if (optional.isPresent()) {
- BlockState iblockdata = worldserver1.getBlockState(blockposition);
- boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
- isAnchorSpawn = flag3; // Paper - Fix anchor respawn acting as a bed respawn from the end portal
- Vec3 vec3d = (Vec3) optional.get();
- float f1;
+ if (optional.isPresent()) {
+ BlockState iblockdata = worldserver1.getBlockState(blockposition);
+ boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
+ isAnchorSpawn = flag3; // Paper - Fix anchor respawn acting as a bed respawn from the end portal
+ Vec3 vec3d = (Vec3) optional.get();
+ float f1;
- if (!iblockdata.is(BlockTags.BEDS) && !flag3) {
- f1 = f;
- } else {
- Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
+ if (!iblockdata.is(BlockTags.BEDS) && !flag3) {
+ f1 = f;
+ } else {
+ Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
- f1 = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
- }
+ f1 = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
+ }
- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // Paper - PlayerSetSpawnEvent
- flag2 = !flag && flag3;
- isBedSpawn = true;
- location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
- } else if (blockposition != null) {
- entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
- entityplayer1.setRespawnPosition(null, null, 0f, false, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent
+ entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // Paper - PlayerSetSpawnEvent
+ flag2 = !flag && flag3;
+ isBedSpawn = true;
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
+ } else if (blockposition != null) {
+ entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent
+ }
}
- }
- if (location == null) {
- worldserver1 = this.server.getLevel(Level.OVERWORLD);
- blockposition = entityplayer1.getSpawnPoint(worldserver1);
- location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F), worldserver1.levelData.getSpawnAngle(), 0.0F); // Paper - use world spawn angle
+ if (location == null) {
+ worldserver1 = this.server.getLevel(Level.OVERWORLD);
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F), worldserver1.levelData.getSpawnAngle(), 0.0F); // Paper - use world spawn angle
+ }
}
- Player respawnPlayer = entityplayer1.getBukkitEntity();
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, com.google.common.collect.ImmutableSet.<org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag>builder().add(respawnFlags)); // Paper - Fix anchor respawn acting as a bed respawn from the end portal
this.cserver.getPluginManager().callEvent(respawnEvent);
// Spigot Start

View File

@@ -1,32 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 12 Aug 2022 11:12:12 -0500
Subject: [PATCH] Disable Azalea generation
diff --git a/src/main/java/net/minecraft/data/worldgen/BiomeDefaultFeatures.java b/src/main/java/net/minecraft/data/worldgen/BiomeDefaultFeatures.java
index 415610172cea5b982222e1c5ad476e43511fcd64..1b544f917dee2b049b7c606c1b1cd87378a15d90 100644
--- a/src/main/java/net/minecraft/data/worldgen/BiomeDefaultFeatures.java
+++ b/src/main/java/net/minecraft/data/worldgen/BiomeDefaultFeatures.java
@@ -161,7 +161,7 @@ public class BiomeDefaultFeatures {
builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.CAVE_VINES);
builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.LUSH_CAVES_CLAY);
builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.LUSH_CAVES_VEGETATION);
- builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.ROOTED_AZALEA_TREE);
+// builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.ROOTED_AZALEA_TREE); // Slice
builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.SPORE_BLOSSOM);
builder.addFeature(GenerationStep.Decoration.VEGETAL_DECORATION, CavePlacements.CLASSIC_VINES);
}
diff --git a/src/main/java/net/minecraft/data/worldgen/features/CaveFeatures.java b/src/main/java/net/minecraft/data/worldgen/features/CaveFeatures.java
index ded33cfbda2d0f6e11cc1304c5ee5b1940b6de04..1e13c9c235c5a9d7d6d2270e837031985f152cbb 100644
--- a/src/main/java/net/minecraft/data/worldgen/features/CaveFeatures.java
+++ b/src/main/java/net/minecraft/data/worldgen/features/CaveFeatures.java
@@ -69,7 +69,7 @@ public class CaveFeatures {
private static final RandomizedIntStateProvider CAVE_VINES_HEAD_PROVIDER = new RandomizedIntStateProvider(new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(Blocks.CAVE_VINES.defaultBlockState(), 4).add(Blocks.CAVE_VINES.defaultBlockState().setValue(CaveVines.BERRIES, Boolean.valueOf(true)), 1)), CaveVinesBlock.AGE, UniformInt.of(23, 25));
public static final Holder<ConfiguredFeature<BlockColumnConfiguration, ?>> CAVE_VINE = FeatureUtils.register("cave_vine", Feature.BLOCK_COLUMN, new BlockColumnConfiguration(List.of(BlockColumnConfiguration.layer(new WeightedListInt(SimpleWeightedRandomList.<IntProvider>builder().add(UniformInt.of(0, 19), 2).add(UniformInt.of(0, 2), 3).add(UniformInt.of(0, 6), 10).build()), CAVE_VINES_BODY_PROVIDER), BlockColumnConfiguration.layer(ConstantInt.of(1), CAVE_VINES_HEAD_PROVIDER)), Direction.DOWN, BlockPredicate.ONLY_IN_AIR_PREDICATE, true));
public static final Holder<ConfiguredFeature<BlockColumnConfiguration, ?>> CAVE_VINE_IN_MOSS = FeatureUtils.register("cave_vine_in_moss", Feature.BLOCK_COLUMN, new BlockColumnConfiguration(List.of(BlockColumnConfiguration.layer(new WeightedListInt(SimpleWeightedRandomList.<IntProvider>builder().add(UniformInt.of(0, 3), 5).add(UniformInt.of(1, 7), 1).build()), CAVE_VINES_BODY_PROVIDER), BlockColumnConfiguration.layer(ConstantInt.of(1), CAVE_VINES_HEAD_PROVIDER)), Direction.DOWN, BlockPredicate.ONLY_IN_AIR_PREDICATE, true));
- public static final Holder<ConfiguredFeature<SimpleBlockConfiguration, ?>> MOSS_VEGETATION = FeatureUtils.register("moss_vegetation", Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(Blocks.FLOWERING_AZALEA.defaultBlockState(), 4).add(Blocks.AZALEA.defaultBlockState(), 7).add(Blocks.MOSS_CARPET.defaultBlockState(), 25).add(Blocks.GRASS.defaultBlockState(), 50).add(Blocks.TALL_GRASS.defaultBlockState(), 10))));
+ public static final Holder<ConfiguredFeature<SimpleBlockConfiguration, ?>> MOSS_VEGETATION = FeatureUtils.register("moss_vegetation", Feature.SIMPLE_BLOCK, new SimpleBlockConfiguration(new WeightedStateProvider(SimpleWeightedRandomList.<BlockState>builder().add(Blocks.MOSS_CARPET.defaultBlockState(), 25).add(Blocks.GRASS.defaultBlockState(), 50).add(Blocks.TALL_GRASS.defaultBlockState(), 10))));
public static final Holder<ConfiguredFeature<VegetationPatchConfiguration, ?>> MOSS_PATCH = FeatureUtils.register("moss_patch", Feature.VEGETATION_PATCH, new VegetationPatchConfiguration(BlockTags.MOSS_REPLACEABLE, BlockStateProvider.simple(Blocks.MOSS_BLOCK), PlacementUtils.inlinePlaced(MOSS_VEGETATION), CaveSurface.FLOOR, ConstantInt.of(1), 0.0F, 5, 0.8F, UniformInt.of(4, 7), 0.3F));
public static final Holder<ConfiguredFeature<VegetationPatchConfiguration, ?>> MOSS_PATCH_BONEMEAL = FeatureUtils.register("moss_patch_bonemeal", Feature.VEGETATION_PATCH, new VegetationPatchConfiguration(BlockTags.MOSS_REPLACEABLE, BlockStateProvider.simple(Blocks.MOSS_BLOCK), PlacementUtils.inlinePlaced(MOSS_VEGETATION), CaveSurface.FLOOR, ConstantInt.of(1), 0.0F, 5, 0.6F, UniformInt.of(1, 2), 0.75F));
public static final Holder<ConfiguredFeature<SimpleRandomFeatureConfiguration, ?>> DRIPLEAF = FeatureUtils.register("dripleaf", Feature.SIMPLE_RANDOM_SELECTOR, new SimpleRandomFeatureConfiguration(HolderSet.direct(makeSmallDripleaf(), makeDripleaf(Direction.EAST), makeDripleaf(Direction.WEST), makeDripleaf(Direction.SOUTH), makeDripleaf(Direction.NORTH))));

View File

@@ -1,149 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:40:09 -0500
Subject: [PATCH] Set multiple Team settings at once
diff --git a/src/main/java/net/minecraft/world/scores/PlayerTeam.java b/src/main/java/net/minecraft/world/scores/PlayerTeam.java
index 9464054912e19fc78dd965b71fce20a18564b351..1624a0f8ea211a4c43fd01612674ca501c10d7e6 100644
--- a/src/main/java/net/minecraft/world/scores/PlayerTeam.java
+++ b/src/main/java/net/minecraft/world/scores/PlayerTeam.java
@@ -28,6 +28,7 @@ public class PlayerTeam extends Team {
private ChatFormatting color = ChatFormatting.RESET;
private Team.CollisionRule collisionRule = Team.CollisionRule.ALWAYS;
private final Style displayNameStyle;
+ private boolean updateTeamChangeInstantly = true; // Slice
public PlayerTeam(Scoreboard scoreboard, String name) {
this.scoreboard = scoreboard;
@@ -36,6 +37,12 @@ public class PlayerTeam extends Team {
this.displayNameStyle = Style.EMPTY.withInsertion(name).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(name)));
}
+ // Slice start
+ public void setUpdateTeamChangeInstantly(boolean updateTeamChangeInstantly) {
+ this.updateTeamChangeInstantly = updateTeamChangeInstantly;
+ }
+ // Slice end
+
public Scoreboard getScoreboard() {
return this.scoreboard;
}
@@ -64,13 +71,13 @@ public class PlayerTeam extends Team {
throw new IllegalArgumentException("Name cannot be null");
} else {
this.displayName = displayName;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
}
public void setPlayerPrefix(@Nullable Component prefix) {
this.playerPrefix = prefix == null ? CommonComponents.EMPTY : prefix;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
public Component getPlayerPrefix() {
@@ -79,7 +86,7 @@ public class PlayerTeam extends Team {
public void setPlayerSuffix(@Nullable Component suffix) {
this.playerSuffix = suffix == null ? CommonComponents.EMPTY : suffix;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
public Component getPlayerSuffix() {
@@ -113,7 +120,7 @@ public class PlayerTeam extends Team {
public void setAllowFriendlyFire(boolean friendlyFire) {
this.allowFriendlyFire = friendlyFire;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
@Override
@@ -123,7 +130,7 @@ public class PlayerTeam extends Team {
public void setSeeFriendlyInvisibles(boolean showFriendlyInvisible) {
this.seeFriendlyInvisibles = showFriendlyInvisible;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
@Override
@@ -138,12 +145,12 @@ public class PlayerTeam extends Team {
public void setNameTagVisibility(Team.Visibility nameTagVisibilityRule) {
this.nameTagVisibility = nameTagVisibilityRule;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
public void setDeathMessageVisibility(Team.Visibility deathMessageVisibilityRule) {
this.deathMessageVisibility = deathMessageVisibilityRule;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
@Override
@@ -153,7 +160,7 @@ public class PlayerTeam extends Team {
public void setCollisionRule(Team.CollisionRule collisionRule) {
this.collisionRule = collisionRule;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
public int packOptions() {
@@ -176,7 +183,7 @@ public class PlayerTeam extends Team {
public void setColor(ChatFormatting color) {
this.color = color;
- this.scoreboard.onTeamChanged(this);
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index 67efb0d38ae369ff5254f7b1ec85d32d4eee8291..e4110e3a60242b958c9983a090b28aae540b2bdf 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -347,6 +347,37 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
}
}
+ //Slice start
+ @Override
+ public void teamOptions(net.kyori.adventure.text.Component displayName,
+ net.kyori.adventure.text.Component prefix,
+ net.kyori.adventure.text.Component suffix,
+ net.kyori.adventure.text.format.NamedTextColor color,
+ java.util.List<org.apache.commons.lang3.tuple.Pair<Option, OptionStatus>> options) throws IllegalStateException {
+ checkState();
+ team.setUpdateTeamChangeInstantly(false);
+
+ if (displayName == null) displayName = net.kyori.adventure.text.Component.empty();
+ team.setDisplayName(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName));
+
+ if (prefix == null) prefix = net.kyori.adventure.text.Component.empty();
+ team.setPlayerPrefix(io.papermc.paper.adventure.PaperAdventure.asVanilla(prefix));
+
+ if (suffix == null) suffix = net.kyori.adventure.text.Component.empty();
+ team.setPlayerSuffix(io.papermc.paper.adventure.PaperAdventure.asVanilla(suffix));
+
+ if (color == null) color = net.kyori.adventure.text.format.NamedTextColor.WHITE;
+ team.setColor(io.papermc.paper.adventure.PaperAdventure.asVanilla(color));
+
+ for (org.apache.commons.lang3.tuple.Pair<Option, OptionStatus> pair : options) {
+ setOption(pair.getLeft(), pair.getRight());
+ }
+
+ team.setUpdateTeamChangeInstantly(true);
+ team.getScoreboard().onTeamChanged(team);
+ }
+ //Slice end
+
// Paper start
@Override
public void addEntity(org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException {

View File

@@ -1,57 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 08:58:14 -0500
Subject: [PATCH] Smooth Teleports
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 9c9b4d7e0637348a94befce9377fdb69c1239694..46ff63d0a2c05c67bcedccc2827120f088acd066 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -266,6 +266,7 @@ public class ServerPlayer extends Player {
public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
+ public boolean smoothWorldTeleport; // Slice
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, @Nullable ProfilePublicKey publicKey) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile, publicKey);
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 6f0efd3459da45e4aa3a59e8b647725b779cdf51..3b3a4d7b1e94c8a9be64e3423654a1490b762ef9 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -966,12 +966,12 @@ public abstract class PlayerList {
}
// CraftBukkit start
LevelData worlddata = worldserver1.getLevelData();
- entityplayer1.connection.send(new ClientboundRespawnPacket(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag, entityplayer1.getLastDeathLocation()));
+ if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.send(new ClientboundRespawnPacket(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag, entityplayer1.getLastDeathLocation()));
entityplayer1.connection.send(new ClientboundSetChunkCacheRadiusPacket(worldserver1.getChunkSource().chunkMap.playerChunkManager.getTargetSendDistance())); // Spigot // Paper - replace old player chunk management
entityplayer1.connection.send(new ClientboundSetSimulationDistancePacket(worldserver1.getChunkSource().chunkMap.playerChunkManager.getTargetTickViewDistance())); // Spigot // Paper - replace old player chunk management
entityplayer1.spawnIn(worldserver1);
entityplayer1.unsetRemoved();
- entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
+ if (!entityplayer.smoothWorldTeleport) entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
entityplayer1.setShiftKeyDown(false);
// entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 3c301c3621cfc3c99788064231af7e106f418e3b..fb2703bc25242fe82e989032175e138ffa0b46b4 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1216,6 +1216,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end
}
+ // Slice start
+ public void teleportWithoutRespawn(Location location) {
+ ServerPlayer serverPlayer = getHandle();
+ serverPlayer.smoothWorldTeleport = true;
+ teleport(location);
+ serverPlayer.smoothWorldTeleport = false;
+ }
+ // Slice end
+
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
// Paper start - Teleport API

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 13 Aug 2022 09:10:38 -0500
Subject: [PATCH] Allow access to LightEngine
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 55d8ced734a408c990c6c4fbc81707bcb1f27daa..3fc426cb23ccf9baf922eca0aaca866cd1994cba 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -494,7 +494,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return !ChunkMap.isChunkInRange(x1, z1, x2, z2, distance) ? false : (!ChunkMap.isChunkInRange(x1 + 1, z1, x2, z2, distance) ? true : (!ChunkMap.isChunkInRange(x1, z1 + 1, x2, z2, distance) ? true : (!ChunkMap.isChunkInRange(x1 - 1, z1, x2, z2, distance) ? true : !ChunkMap.isChunkInRange(x1, z1 - 1, x2, z2, distance))));
}
- protected ThreadedLevelLightEngine getLightEngine() {
+ public ThreadedLevelLightEngine getLightEngine() { // Slice (public)
return this.lightEngine;
}

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 16 Aug 2022 08:27:13 -0500
Subject: [PATCH] Unfreeze MappedRegistry
diff --git a/src/main/java/net/minecraft/core/MappedRegistry.java b/src/main/java/net/minecraft/core/MappedRegistry.java
index 3ef5d440fd3ce209110543bfd36569e846a5b749..7afb07a24c21706473c28a058214e81ebff1ab0a 100644
--- a/src/main/java/net/minecraft/core/MappedRegistry.java
+++ b/src/main/java/net/minecraft/core/MappedRegistry.java
@@ -331,6 +331,8 @@ public class MappedRegistry<T> extends WritableRegistry<T> {
@Override
public Registry<T> freeze() {
+ if (true) return this; // Slice (a TODO in Paper, thanks Owen)
+
this.frozen = true;
List<ResourceLocation> list = this.byKey.entrySet().stream().filter((entry) -> {
return !entry.getValue().isBound();

View File

@@ -1,218 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:02:11 -0600
Subject: [PATCH] Equipment Packet Caching
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
index 5a8f850b447fc3a4bd0eb0c505bbdfc8be7115e8..997c9656c9cf815ad2769d4dea6f67a2301fca7c 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
@@ -18,6 +18,17 @@ public class ClientboundSetEquipmentPacket implements Packet<ClientGamePacketLis
this.slots = equipmentList;
}
+ // Slice start
+ public ClientboundSetEquipmentPacket(int id, List<Pair<EquipmentSlot, ItemStack>> equipmentList, net.minecraft.world.entity.LivingEntity entity, String tag) {
+ this.entity = id;
+ slots = new java.util.ArrayList<>(equipmentList.size());
+ for (Pair<EquipmentSlot, ItemStack> pair : equipmentList) {
+ EquipmentSlot slot = pair.getFirst();
+ slots.add(Pair.of(slot, entity.getOrCreateCachedEquipmentItem(tag, slot, pair.getSecond())));
+ }
+ }
+ // Slice end
+
public ClientboundSetEquipmentPacket(FriendlyByteBuf buf) {
this.entity = buf.readVarInt();
EquipmentSlot[] equipmentSlots = EquipmentSlot.values();
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 8b30e408d12ccabb66f94829879781e88023f271..52d021c87b40906a546678af6aa030843e6e669b 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -300,27 +300,8 @@ public class ServerEntity {
consumer.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap));
}
- if (this.entity instanceof LivingEntity) {
- List<Pair<EquipmentSlot, ItemStack>> list = Lists.newArrayList();
- EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
- int i = aenumitemslot.length;
-
- for (int j = 0; j < i; ++j) {
- EquipmentSlot enumitemslot = aenumitemslot[j];
- ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot);
-
- if (!itemstack.isEmpty()) {
- // Paper start - prevent oversized data
- final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false);
- list.add(Pair.of(enumitemslot, ((LivingEntity) this.entity).stripMeta(sanitized, false))); // Paper - remove unnecessary item meta
- // Paper end
- }
- }
-
- if (!list.isEmpty()) {
- consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list));
- }
- ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
+ if (this.entity instanceof LivingEntity livingEntity) {
+ livingEntity.sendEquipment(entityplayer); // Slice
}
// CraftBukkit start - Fix for nonsensical head yaw
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index be20f0971d34804b95f939896594f747497fde53..7e996a81b20c37a0570c21887b01490d106457e8 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -265,6 +265,8 @@ public abstract class LivingEntity extends Entity {
public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper
+ private final com.google.common.collect.Table<String, ItemStack, ItemStack> equipmentPacketCache = com.google.common.collect.HashBasedTable.create(); // Slice
+ public java.util.Map<String, net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket> cachedEquipmentMap = new java.util.HashMap<>(); // Slice
@Override
public float getBukkitYaw() {
@@ -3057,6 +3059,7 @@ public abstract class LivingEntity extends Entity {
if (map != null) {
this.handleHandSwap(map);
if (!map.isEmpty()) {
+ cachedEquipmentMap.clear(); // Slice - Must invalidate cached equipment map if we have changes
this.handleEquipmentChanges(map);
}
}
@@ -3145,7 +3148,25 @@ public abstract class LivingEntity extends Entity {
}
});
- ((ServerLevel) this.level).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
+
+ // Slice start
+ net.minecraft.server.level.ChunkMap.TrackedEntity entityTracker = ((ServerLevel) this.level).getChunkSource().chunkMap.entityMap.get(getId());
+ if (entityTracker != null) {
+ ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(this.getId(), list);
+ for (net.minecraft.server.network.ServerPlayerConnection playerConnection : entityTracker.seenBy) {
+ ServerPlayer player = playerConnection.getPlayer();
+ org.bukkit.event.player.PlayerReceiveEquipmentEvent event = new org.bukkit.event.player.PlayerReceiveEquipmentEvent(player.getBukkitEntity(), getBukkitEntity());
+ level.getCraftServer().getPluginManager().callEvent(event);
+
+ String tag = event.getTag();
+ if (tag != null) {
+ playerConnection.send(new ClientboundSetEquipmentPacket(this.getId(), list, this, tag));
+ } else {
+ playerConnection.send(packet);
+ }
+ }
+ }
+ // Slice end
}
// Paper start - hide unnecessary item meta
@@ -4413,4 +4434,72 @@ public abstract class LivingEntity extends Entity {
public static record Fallsounds(SoundEvent small, SoundEvent big) {
}
+
+ // Slice start
+ public void sendEquipment(ServerPlayer p) {
+ org.bukkit.event.player.PlayerReceiveEquipmentEvent event = new org.bukkit.event.player.PlayerReceiveEquipmentEvent(p.getBukkitEntity(), getBukkitEntity());
+ level.getCraftServer().getPluginManager().callEvent(event);
+
+ boolean sendEquipment = !event.isCancelled();
+ String tag = event.getTag();
+ if (sendEquipment && this instanceof ServerPlayer player && tag != null) {
+ ClientboundSetEquipmentPacket equipmentPacket = player.cachedEquipmentMap.get(tag);
+ if (equipmentPacket != null) {
+ //Event says use a tag, and our tag exists; so we simply used our entire cached packet
+ p.connection.send(equipmentPacket);
+ sendEquipment = false;
+ }
+ }
+
+ if (sendEquipment) {
+ EquipmentSlot[] equipmentSlots = EquipmentSlot.values();
+ List<Pair<EquipmentSlot, ItemStack>> list = new ArrayList<>(equipmentSlots.length);
+
+ for (EquipmentSlot enumitemslot : equipmentSlots) {
+ ItemStack itemstack = getItemBySlot(enumitemslot);
+
+ if (!itemstack.isEmpty()) {
+ // Paper start - prevent oversized data
+ final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false);
+ ItemStack strippedItem = stripMeta(sanitized, false);
+
+ if (tag != null) {
+ strippedItem = getOrCreateCachedEquipmentItem(tag, enumitemslot, strippedItem);
+ }
+
+ list.add(Pair.of(enumitemslot, strippedItem)); // Paper - remove unnecessary item meta
+ // Paper end
+ }
+ }
+
+ if (!list.isEmpty()) {
+ ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(getId(), list);
+ if (tag != null) {
+ cachedEquipmentMap.put(tag, equipmentPacket);
+ }
+ p.connection.send(equipmentPacket);
+ }
+
+ detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
+ }
+ }
+
+ public ItemStack getOrCreateCachedEquipmentItem(String tag, EquipmentSlot slot, ItemStack itemStack) {
+ return equipmentPacketCache.row(tag).computeIfAbsent(itemStack, i -> {
+ String name = slot.name();
+
+ //How neat is this.
+ if (name.equals("MAINHAND")) {
+ name = "HAND";
+ } else if (name.equals("OFFHAND")) {
+ name = "OFF_HAND";
+ }
+
+ org.bukkit.event.entity.EntityEquipmentItemLookup event = new org.bukkit.event.entity.EntityEquipmentItemLookup(getBukkitEntity(), tag, org.bukkit.inventory.EquipmentSlot.valueOf(name), CraftItemStack.asBukkitCopy(i));
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ org.bukkit.inventory.ItemStack eventItem = event.getItemStack();
+ return CraftItemStack.asNMSCopy(eventItem);
+ });
+ }
+ // Slice end
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index c77fec21a4e988da14af15dfd45a565c0cd7df00..f1b9cbc0642a92cae2424b2f16e9c9bf71f76141 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -707,7 +707,11 @@ public final class ItemStack {
}
public static boolean isSameIgnoreDurability(ItemStack left, ItemStack right) {
- return left == right ? true : (!left.isEmpty() && !right.isEmpty() ? left.sameItemStackIgnoreDurability(right) : false);
+ // Slice start
+ boolean rightEmpty = right.isEmpty();
+ boolean leftEmpty = left.isEmpty();
+ return left == right || leftEmpty && rightEmpty ? true : (!leftEmpty && !rightEmpty ? left.sameItemStackIgnoreDurability(right) : false);
+ // Slice end
}
public boolean sameItem(ItemStack stack) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 316120a57802c45fb9b02a4daee207a0845c63be..df3d23c8465baed13eda276c2b0750de61bdb473 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -1043,4 +1043,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
getHandle().knockback(strength, directionX, directionZ);
};
// Paper end
+
+ // Slice start
+ @Override
+ public void sendEquipment(Player p) {
+ if (entity instanceof net.minecraft.world.entity.LivingEntity livingEntity) {
+ livingEntity.sendEquipment(((CraftPlayer) p).getHandle());
+ }
+ }
+ // Slice end
}

View File

@@ -1,48 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:03:19 -0600
Subject: [PATCH] AntiXray Bypass
diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
index dabd93c35bdbac6a8b668a82d5f3d4173a1baa4a..3c144e41dbe5735fb72094281596e22e95eea082 100644
--- a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
+++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java
@@ -162,6 +162,7 @@ public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockCo
@Override
public boolean shouldModify(ServerPlayer player, LevelChunk chunk) {
+ if (player.getBukkitEntity().hasAntiXrayBypass()) return false; // Slice
return !usePermission || !player.getBukkitEntity().hasPermission("paper.antixray.bypass");
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index fb2703bc25242fe82e989032175e138ffa0b46b4..83b4bc9238a8adbebfd0dd62b99075632e79281a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -176,6 +176,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
private long lastSaveTime;
// Paper end
+ private boolean antiXrayBypass; // Slice
public CraftPlayer(CraftServer server, ServerPlayer entity) {
super(server, entity);
@@ -2596,6 +2597,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Slice start
+ public boolean hasAntiXrayBypass() {
+ return this.antiXrayBypass;
+ }
+
+ @Override
+ public void toggleAntiXrayBypass(boolean bypass) {
+ this.antiXrayBypass = bypass;
+ }
+ // Slice end
+
@Override
public void updateCommands() {
if (this.getHandle().connection == null) return;

View File

@@ -1,53 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:06:31 -0600
Subject: [PATCH] PlayerPreChunkLoadEvent
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
index 0b060183429f4c72ec767075538477b4302bbf0d..e4461c176682644d842b15b833c662039333d24f 100644
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
@@ -787,7 +787,7 @@ public final class PlayerChunkLoader {
// warning: modifications of this field must be aware that the loadQueue inside PlayerChunkLoader uses this field
// in a comparator!
protected final ArrayDeque<ChunkPriorityHolder> loadQueue = new ArrayDeque<>();
- protected final LongOpenHashSet sentChunks = new LongOpenHashSet();
+ public final LongOpenHashSet sentChunks = new LongOpenHashSet(); // Slice - public
protected final LongOpenHashSet chunksToBeSent = new LongOpenHashSet();
protected final TreeSet<ChunkPriorityHolder> sendQueue = new TreeSet<>((final ChunkPriorityHolder p1, final ChunkPriorityHolder p2) -> {
@@ -871,7 +871,14 @@ public final class PlayerChunkLoader {
}
public void sendChunk(final int chunkX, final int chunkZ, final Runnable onChunkSend) {
- if (this.sentChunks.add(CoordinateUtils.getChunkKey(chunkX, chunkZ))) {
+ // Slice start
+ if (!new io.papermc.paper.event.packet.PlayerPreChunkLoadEvent(this.player.getBukkitEntity().getWorld(), chunkX, chunkZ, this.player.getBukkitEntity()).callEvent()) {
+ this.player.connection.connection.execute(onChunkSend);
+ return;
+ }
+ // Slice end
+
+ if (this.sentChunks.add(CoordinateUtils.getChunkKey(chunkX, chunkZ))) { // Slice
this.player.getLevel().getChunkSource().chunkMap.updateChunkTracking(this.player,
new ChunkPos(chunkX, chunkZ), new MutableObject<>(), false, true); // unloaded, loaded
this.player.connection.connection.execute(onChunkSend);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 6d92d1e1301555dd77968e9f1d7347497200dd63..24b7ea846bf19a99f670a40e3623578cfa888282 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -524,6 +524,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return true;
}
+ @Override
+ public it.unimi.dsi.fastutil.longs.LongOpenHashSet getSentChunks(Player p) {
+ CraftPlayer craftPlayer = (CraftPlayer) p;
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = this.world.chunkSource.chunkMap.playerChunkManager.getData(craftPlayer.getHandle());
+ return data != null ? data.sentChunks : null;
+ }
+
@Override
public boolean isChunkInUse(int x, int z) {
return this.isChunkLoaded(x, z);

View File

@@ -1,112 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Fri, 18 Nov 2022 08:37:19 -0600
Subject: [PATCH] Shared DataStorage for maps
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
index 5982dda61e07f1661b0a68d0ba1fcc1122e8d428..4635d78d194f28fb56e436383124f3f5a9fc9d2e 100644
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -360,6 +360,7 @@ public class WorldConfiguration extends ConfigurationPart {
public class Maps extends ConfigurationPart {
public int itemFrameCursorLimit = 128;
public int itemFrameCursorUpdateInterval = 10;
+ public String sharedDataFolder; // Slice
}
public Fixes fixes;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index eb6a4127acba7647d3cec0ec2f51c18ea6f22186..08aac55ad66e982b62d7baa52dd2b36ea97a27c0 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -227,6 +227,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
return thr;
}
+ private @Nullable DimensionDataStorage sharedDataStorage; // Slice
+
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper
}
@@ -606,6 +608,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.chunkTaskScheduler = new io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler(this, io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.workerThreads); // Paper - rewrite chunk system
this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system
+
+ // Slice start
+ String sharedDataFolder = paperConfig().maps.sharedDataFolder;
+ if (sharedDataFolder != null) {
+ java.io.File sharedDir = new java.io.File(sharedDataFolder);
+ sharedDir.mkdirs();
+ this.sharedDataStorage = new DimensionDataStorage(sharedDir, datafixer);
+ }
+ // Slice end
}
public void setWeatherParameters(int clearDuration, int rainDuration, boolean raining, boolean thundering) {
@@ -1319,6 +1330,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}// Paper
// Paper - rewrite chunk system - entity saving moved into ChunkHolder
+ if (sharedDataStorage != null) sharedDataStorage.save();
} else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system
// CraftBukkit start - moved from MinecraftServer.saveChunks
@@ -1945,11 +1957,17 @@ public class ServerLevel extends Level implements WorldGenLevel {
return this.getChunkSource().getDataStorage();
}
+ // Slice start
+ public DimensionDataStorage getMapDataStorage() {
+ return sharedDataStorage != null ? sharedDataStorage : this.getChunkSource().getDataStorage();
+ }
+ // Slice end
+
@Nullable
@Override
public MapItemSavedData getMapData(String id) {
// CraftBukkit start
- return (MapItemSavedData) this.getServer().overworld().getDataStorage().get((nbttagcompound) -> {
+ return (MapItemSavedData) getMapDataStorage().get((nbttagcompound) -> { // Slice
// We only get here when the data file exists, but is not a valid map
MapItemSavedData newMap = MapItemSavedData.load(nbttagcompound);
newMap.id = id;
@@ -1963,12 +1981,22 @@ public class ServerLevel extends Level implements WorldGenLevel {
@Override
public void setMapData(String id, MapItemSavedData state) {
state.id = id; // CraftBukkit
- this.getServer().overworld().getDataStorage().set(id, state);
+ getMapDataStorage().set(id, state); // Slice
}
@Override
public int getFreeMapId() {
- return ((MapIndex) this.getServer().overworld().getDataStorage().computeIfAbsent(MapIndex::load, MapIndex::new, "idcounts")).getFreeAuxValueForMap();
+ // Slice start
+ DimensionDataStorage storage = getMapDataStorage();
+ MapIndex mapIndex = storage.readSavedData(MapIndex::load, "idcounts");
+ if (mapIndex == null) {
+ mapIndex = new MapIndex();
+ }
+ int newId = mapIndex.getFreeAuxValueForMap();
+ storage.set("idcounts", mapIndex);
+ storage.save();
+ return newId;
+ // Slice end
}
// Paper start - helper function for configurable spawn radius
diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
index 2513069f4ffe594857762ef51f1b9a078b8b1d17..88b13bfa3393d9901c8a1b62bcc37f03919d747b 100644
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
@@ -58,7 +58,7 @@ public class DimensionDataStorage {
}
@Nullable
- private <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, String id) {
+ public <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, String id) { // Slice private -> public
try {
File file = this.getDataFile(id);
if (file.exists()) {

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 3 Dec 2022 06:58:09 -0600
Subject: [PATCH] Set COOKED_MUTTON nutrition equal to COOKED_BEEF
diff --git a/src/main/java/net/minecraft/world/food/Foods.java b/src/main/java/net/minecraft/world/food/Foods.java
index b16d9e2eaa589f19c563ee70b1a56d67dbcdecb0..c6ff08efc7f0c0e782f8e78e01b9d9cea5cdcaed 100644
--- a/src/main/java/net/minecraft/world/food/Foods.java
+++ b/src/main/java/net/minecraft/world/food/Foods.java
@@ -17,7 +17,7 @@ public class Foods {
public static final FoodProperties COOKED_BEEF = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.8F).meat().build();
public static final FoodProperties COOKED_CHICKEN = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.6F).meat().build();
public static final FoodProperties COOKED_COD = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.6F).build();
- public static final FoodProperties COOKED_MUTTON = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).meat().build();
+ public static final FoodProperties COOKED_MUTTON = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.8F).meat().build();
public static final FoodProperties COOKED_PORKCHOP = (new FoodProperties.Builder()).nutrition(8).saturationMod(0.8F).meat().build();
public static final FoodProperties COOKED_RABBIT = (new FoodProperties.Builder()).nutrition(5).saturationMod(0.6F).meat().build();
public static final FoodProperties COOKED_SALMON = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.8F).build();

View File

@@ -1,59 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Thu, 15 Dec 2022 15:48:34 -0600
Subject: [PATCH] Player-specific target chunk send rate
diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
index e4461c176682644d842b15b833c662039333d24f..9dabd5bb2d9e6c2f9a6dc7103ca914478b17cd60 100644
--- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java
@@ -386,8 +386,8 @@ public final class PlayerChunkLoader {
return (int)Math.ceil(Math.min(config * MinecraftServer.getServer().getPlayerCount(), max <= 1.0 ? Double.MAX_VALUE : max));
}
- protected long getTargetSendPerPlayerAddend() {
- return GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate);
+ protected long getTargetSendPerPlayerAddend(ServerPlayer player) { // Slice
+ return player.targetChunkSendRate <= 1.0 ? 0L : (long)Math.round(1.0e9 / player.targetChunkSendRate); // Slice
}
protected long getMaxSendAddend() {
@@ -541,7 +541,6 @@ public final class PlayerChunkLoader {
}
final int maxSends = this.getMaxConcurrentChunkSends();
- final long nextPlayerDeadline = this.getTargetSendPerPlayerAddend() + time;
for (;;) {
if (this.chunkSendQueue.isEmpty()) {
break;
@@ -574,7 +573,7 @@ public final class PlayerChunkLoader {
throw new IllegalStateException();
}
- data.nextChunkSendTarget = nextPlayerDeadline;
+ data.nextChunkSendTarget = this.getTargetSendPerPlayerAddend(data.player) + time; // Slice
this.chunkSendWaitQueue.add(data);
synchronized (this.sendingChunkCounts) {
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 46ff63d0a2c05c67bcedccc2827120f088acd066..b30d6d9e8a4157d3238bad6ea68b4de52f27334b 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -13,6 +13,8 @@ import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import javax.annotation.Nullable;
+
+import io.papermc.paper.configuration.GlobalConfiguration;
import net.minecraft.BlockUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.CrashReport;
@@ -267,6 +269,7 @@ public class ServerPlayer extends Player {
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
public boolean smoothWorldTeleport; // Slice
+ public double targetChunkSendRate = GlobalConfiguration.get().chunkLoading.targetPlayerChunkSendRate; // Slice
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, @Nullable ProfilePublicKey publicKey) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile, publicKey);