moaaaaar patches
This commit is contained in:
parent
e141126891
commit
6f5b43e290
23 changed files with 50 additions and 69 deletions
|
@ -1,78 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kennytv <jahnke.nassim@gmail.com>
|
||||
Date: Fri, 29 Jan 2021 15:13:04 +0100
|
||||
Subject: [PATCH] Add dropLeash variable to EntityUnleashEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||
index a33986a0c437a673435206fc337031a7eebdab3b..e0e068799a1868c8e561869015f41f553ef4fbdb 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java
|
||||
@@ -10,10 +10,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class EntityUnleashEvent extends EntityEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final UnleashReason reason;
|
||||
+ private boolean dropLeash; // Paper
|
||||
|
||||
+ // Paper start - drop leash variable
|
||||
+ @Deprecated
|
||||
public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) {
|
||||
+ this(entity, reason, false);
|
||||
+ }
|
||||
+
|
||||
+ public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason, boolean dropLeash) {
|
||||
super(entity);
|
||||
+ // Paper end
|
||||
this.reason = reason;
|
||||
+ this.dropLeash = dropLeash; // Paper
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,6 +35,26 @@ public class EntityUnleashEvent extends EntityEvent {
|
||||
return reason;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Returns whether a leash item will be dropped.
|
||||
+ *
|
||||
+ * @return Whether the leash item will be dropped
|
||||
+ */
|
||||
+ public boolean isDropLeash() {
|
||||
+ return dropLeash;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether a leash item should be dropped.
|
||||
+ *
|
||||
+ * @param dropLeash Whether the leash item should be dropped
|
||||
+ */
|
||||
+ public void setDropLeash(boolean dropLeash) {
|
||||
+ this.dropLeash = dropLeash;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
|
||||
index cf78950b56d4977f6c4d9d98d183bfc5ba3bacc0..68eab1563caba1ee4f52b308f390e4e172667fc5 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java
|
||||
@@ -13,8 +13,15 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc
|
||||
private final Player player;
|
||||
private boolean cancelled = false;
|
||||
|
||||
+ // Paper start - drop leash variable
|
||||
+ @Deprecated
|
||||
public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player) {
|
||||
- super(entity, UnleashReason.PLAYER_UNLEASH);
|
||||
+ this(entity, player, false);
|
||||
+ }
|
||||
+
|
||||
+ public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, boolean dropLeash) {
|
||||
+ super(entity, UnleashReason.PLAYER_UNLEASH, dropLeash);
|
||||
+ // Paper end
|
||||
this.player = player;
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Tue, 11 Feb 2020 21:56:38 -0600
|
||||
Subject: [PATCH] EntityMoveEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..245d56ba7e8e37e3555b606f5e85fc663897f62b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/entity/EntityMoveEvent.java
|
||||
@@ -0,0 +1,143 @@
|
||||
+package io.papermc.paper.event.entity;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.bukkit.event.player.PlayerMoveEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Holds information for living entity movement events
|
||||
+ * <p>
|
||||
+ * Does not fire for players; use {@link PlayerMoveEvent} for player movement.
|
||||
+ */
|
||||
+public class EntityMoveEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean canceled;
|
||||
+ private Location from;
|
||||
+ private Location to;
|
||||
+
|
||||
+ public EntityMoveEvent(@NotNull LivingEntity entity, @NotNull Location from, @NotNull Location to) {
|
||||
+ super(entity);
|
||||
+ this.from = from;
|
||||
+ this.to = to;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public LivingEntity getEntity() {
|
||||
+ return (LivingEntity) entity;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCancelled() {
|
||||
+ return canceled;
|
||||
+ }
|
||||
+
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ canceled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location this entity moved from
|
||||
+ *
|
||||
+ * @return Location the entity moved from
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getFrom() {
|
||||
+ return from;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location to mark as where the entity moved from
|
||||
+ *
|
||||
+ * @param from New location to mark as the entity's previous location
|
||||
+ */
|
||||
+ public void setFrom(@NotNull Location from) {
|
||||
+ validateLocation(from);
|
||||
+ this.from = from;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location this entity moved to
|
||||
+ *
|
||||
+ * @return Location the entity moved to
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getTo() {
|
||||
+ return to;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location that this entity will move to
|
||||
+ *
|
||||
+ * @param to New Location this entity will move to
|
||||
+ */
|
||||
+ public void setTo(@NotNull Location to) {
|
||||
+ validateLocation(to);
|
||||
+ this.to = to;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the entity has changed position (even within the same block) in the event
|
||||
+ *
|
||||
+ * @return whether the entity has changed position or not
|
||||
+ */
|
||||
+ public boolean hasChangedPosition() {
|
||||
+ return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the entity has changed position (even within the same block) in the event, disregarding a possible world change
|
||||
+ *
|
||||
+ * @return whether the entity has changed position or not
|
||||
+ */
|
||||
+ public boolean hasExplicitlyChangedPosition() {
|
||||
+ return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the entity has moved to a new block in the event
|
||||
+ *
|
||||
+ * @return whether the entity has moved to a new block or not
|
||||
+ */
|
||||
+ public boolean hasChangedBlock() {
|
||||
+ return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the entity has moved to a new block in the event, disregarding a possible world change
|
||||
+ *
|
||||
+ * @return whether the entity has moved to a new block or not
|
||||
+ */
|
||||
+ public boolean hasExplicitlyChangedBlock() {
|
||||
+ return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Check if the entity has changed orientation in the event
|
||||
+ *
|
||||
+ * @return whether the entity has changed orientation or not
|
||||
+ */
|
||||
+ public boolean hasChangedOrientation() {
|
||||
+ return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw();
|
||||
+ }
|
||||
+
|
||||
+ private void validateLocation(@NotNull Location loc) {
|
||||
+ Preconditions.checkArgument(loc != null, "Cannot use null location!");
|
||||
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
|
@ -1,75 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Trigary <trigary0@gmail.com>
|
||||
Date: Mon, 25 Jan 2021 14:53:49 +0100
|
||||
Subject: [PATCH] add DragonEggFormEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5495b87330518363498e1ac5d8f0a832be35fefb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/block/DragonEggFormEvent.java
|
||||
@@ -0,0 +1,63 @@
|
||||
+package io.papermc.paper.event.block;
|
||||
+
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.boss.DragonBattle;
|
||||
+import org.bukkit.entity.EnderDragon;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockFormEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle},
|
||||
+ * causing a {@link Material#DRAGON_EGG} (more formally: {@link #getNewState()})
|
||||
+ * to possibly appear depending on {@link #isCancelled()}.
|
||||
+ * <b>This event might be cancelled by default depending on
|
||||
+ * eg. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b>
|
||||
+ */
|
||||
+public class DragonEggFormEvent extends BlockFormEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final DragonBattle dragonBattle;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public DragonEggFormEvent(@NotNull Block block, @NotNull BlockState newState,
|
||||
+ @NotNull DragonBattle dragonBattle) {
|
||||
+ super(block, newState);
|
||||
+ this.dragonBattle = dragonBattle;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancelled) {
|
||||
+ this.cancelled = cancelled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the {@link DragonBattle} associated with this event.
|
||||
+ * Keep in mind that the {@link EnderDragon} is already dead
|
||||
+ * when this event is called.
|
||||
+ *
|
||||
+ * @return the dragon battle
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public DragonBattle getDragonBattle() {
|
||||
+ return dragonBattle;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Wed, 20 Jan 2021 14:25:26 -0600
|
||||
Subject: [PATCH] Allow adding items to BlockDropItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java
|
||||
index a0f6f1af304190b4c5db4b284d460f625eeb7801..3dd4bd38e72c04e74e5787fb38ca9abd10bad06b 100644
|
||||
--- a/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java
|
||||
@@ -64,7 +64,7 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable {
|
||||
* Gets list of the Item drops caused by the block break.
|
||||
*
|
||||
* This list is mutable - removing an item from it will cause it to not
|
||||
- * drop. It is not legal however to add new items to the list.
|
||||
+ * drop. Adding to the list is allowed.
|
||||
*
|
||||
* @return The Item the block caused to drop
|
||||
*/
|
|
@ -1,26 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aleksander Jagiello <themolkapl@gmail.com>
|
||||
Date: Sun, 24 Jan 2021 22:17:29 +0100
|
||||
Subject: [PATCH] Add getMainThreadExecutor to BukkitScheduler
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
|
||||
index c239c4de617933d20f75c33f943ba4a88954144e..1ea49965bf72edd862dc0d43e42c61df80966e45 100644
|
||||
--- a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java
|
||||
@@ -457,4 +457,15 @@ public interface BukkitScheduler {
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public BukkitTask runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull BukkitRunnable task, long delay, long period) throws IllegalArgumentException;
|
||||
+
|
||||
+ // Paper start - add getMainThreadExecutor
|
||||
+ /**
|
||||
+ * Returns an executor that will run tasks on the next server tick.
|
||||
+ *
|
||||
+ * @param plugin the reference to the plugin scheduling tasks
|
||||
+ * @return an executor associated with the given plugin
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public java.util.concurrent.Executor getMainThreadExecutor(@NotNull Plugin plugin);
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ysl3000 <yannicklamprecht@live.de>
|
||||
Date: Sat, 24 Oct 2020 16:37:21 +0200
|
||||
Subject: [PATCH] living entity allow attribute registration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/attribute/Attributable.java b/src/main/java/org/bukkit/attribute/Attributable.java
|
||||
index 0ed96b5af0e6e93590882e0ad8239221bcc3f688..474ed1df364a5ca18661d0fbc29901760e39cb07 100644
|
||||
--- a/src/main/java/org/bukkit/attribute/Attributable.java
|
||||
+++ b/src/main/java/org/bukkit/attribute/Attributable.java
|
||||
@@ -17,4 +17,14 @@ public interface Attributable {
|
||||
*/
|
||||
@Nullable
|
||||
AttributeInstance getAttribute(@NotNull Attribute attribute);
|
||||
+
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Registers a generic attribute to that attributable instance.
|
||||
+ * Allows it to add attributes not registered by default to that entity.
|
||||
+ *
|
||||
+ * @param attribute the generic attribute to register
|
||||
+ */
|
||||
+ void registerAttribute(@NotNull Attribute attribute);
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ivan Pekov <ivan@mrivanplays.com>
|
||||
Date: Tue, 5 Jan 2021 10:19:11 +0200
|
||||
Subject: [PATCH] Add missing effects
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Effect.java b/src/main/java/org/bukkit/Effect.java
|
||||
index cf6b94a52d7638a52337045c1b4e7677a3fbd824..5072c5ed2635f92a6d8048b6e019c8f36338b93c 100644
|
||||
--- a/src/main/java/org/bukkit/Effect.java
|
||||
+++ b/src/main/java/org/bukkit/Effect.java
|
||||
@@ -307,7 +307,100 @@ public enum Effect {
|
||||
* block.
|
||||
*/
|
||||
OXIDISED_COPPER_SCRAPE(3005, Type.VISUAL),
|
||||
+ // Paper start - add missing effects
|
||||
+ /**
|
||||
+ * The sound of a wither spawning
|
||||
+ */
|
||||
+ WITHER_SPAWNED(1023, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of an ender dragon dying
|
||||
+ */
|
||||
+ ENDER_DRAGON_DEATH(1028, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of an ender portal being created in the overworld
|
||||
+ */
|
||||
+ END_PORTAL_CREATED_IN_OVERWORLD(1038, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of phantom's bites
|
||||
+ *
|
||||
+ * @deprecated use {@link #PHANTOM_BITE}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ PHANTOM_BITES(1039, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of zombie converting to drowned zombie
|
||||
+ *
|
||||
+ * @deprecated use {@link #ZOMBIE_CONVERTED_TO_DROWNED}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ ZOMBIE_CONVERTS_TO_DROWNED(1040, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of a husk converting to zombie by drowning
|
||||
+ *
|
||||
+ * @deprecated use {@link #HUSK_CONVERTED_TO_ZOMBIE}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ HUSK_CONVERTS_TO_ZOMBIE(1041, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of a grindstone being used
|
||||
+ *
|
||||
+ * @deprecated use {@link #GRINDSTONE_USE}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ GRINDSTONE_USED(1042, Type.SOUND),
|
||||
+ /**
|
||||
+ * The sound of a book page being turned
|
||||
+ *
|
||||
+ * @deprecated use {@link #BOOK_PAGE_TURN}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ BOOK_PAGE_TURNED(1043, Type.SOUND),
|
||||
+ /**
|
||||
+ * Particles displayed when a composter composts
|
||||
+ *
|
||||
+ * @deprecated use {@link #COMPOSTER_FILL_ATTEMPT}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ COMPOSTER_COMPOSTS(1500, Type.VISUAL),
|
||||
+ /**
|
||||
+ * Particles displayed when lava converts a block (either water to stone, or
|
||||
+ * removing existing blocks such as torches)
|
||||
+ *
|
||||
+ * @deprecated use {@link #LAVA_INTERACT}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ LAVA_CONVERTS_BLOCK(1501, Type.VISUAL),
|
||||
+ /**
|
||||
+ * Particles displayd when a redstone torch burns out
|
||||
+ *
|
||||
+ * @deprecated use {@link #REDSTONE_TORCH_BURNOUT}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ REDSTONE_TORCH_BURNS_OUT(1502, Type.VISUAL),
|
||||
+ /**
|
||||
+ * Particles displayed when an ender eye is placed
|
||||
+ *
|
||||
+ * @deprecated use {@link #END_PORTAL_FRAME_FILL}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ ENDER_EYE_PLACED(1503, Type.VISUAL),
|
||||
+ /**
|
||||
+ * Particles displayed when an ender dragon destroys block
|
||||
+ *
|
||||
+ * @deprecated use {@link #ENDER_DRAGON_DESTROY_BLOCK}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ ENDER_DRAGON_DESTROYS_BLOCK(2008, Type.VISUAL),
|
||||
+ /**
|
||||
+ * Particles displayed when a wet sponge vaporizes in nether.
|
||||
+ *
|
||||
+ * @deprecated use {@link #SPONGE_DRY}
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true)
|
||||
+ WET_SPONGE_VAPORIZES_IN_NETHER(2009, Type.VISUAL),
|
||||
;
|
||||
+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
|
||||
+ // Paper end
|
||||
|
||||
private final int id;
|
||||
private final Type type;
|
||||
@@ -367,10 +460,22 @@ public enum Effect {
|
||||
|
||||
static {
|
||||
for (Effect effect : values()) {
|
||||
+ if (!isDeprecated(effect)) // Paper
|
||||
BY_ID.put(effect.id, effect);
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private static boolean isDeprecated(Effect effect) {
|
||||
+ try {
|
||||
+ return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class);
|
||||
+ } catch (NoSuchFieldException e) {
|
||||
+ LOGGER.error("Error getting effect enum field {}", effect.name(), e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Represents the type of an effect.
|
||||
*/
|
||||
diff --git a/src/test/java/org/bukkit/EffectTest.java b/src/test/java/org/bukkit/EffectTest.java
|
||||
index 54e621e86e8fe3414099494d419929b282b33489..759081f15992e07271567d65250f27f14f6c99c3 100644
|
||||
--- a/src/test/java/org/bukkit/EffectTest.java
|
||||
+++ b/src/test/java/org/bukkit/EffectTest.java
|
||||
@@ -5,10 +5,24 @@ import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EffectTest {
|
||||
+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); // Paper
|
||||
+
|
||||
@Test
|
||||
public void getById() {
|
||||
for (Effect effect : Effect.values()) {
|
||||
+ if (!isDeprecated(effect)) // Paper
|
||||
assertThat(Effect.getById(effect.getId()), is(effect));
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ private static boolean isDeprecated(Effect effect) {
|
||||
+ try {
|
||||
+ return Effect.class.getDeclaredField(effect.name()).isAnnotationPresent(Deprecated.class);
|
||||
+ } catch (NoSuchFieldException e) {
|
||||
+ LOGGER.error("Error getting effect enum field {}", effect.name(), e);
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tom <cryptite@gmail.com>
|
||||
Date: Fri, 26 Feb 2021 16:24:25 -0600
|
||||
Subject: [PATCH] Expose Tracked Players
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index b02704b0535522c5535b560105eec2885fdd3e77..d515de1c316f14165ee327bc81f0be98b60db3bf 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -760,5 +760,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
* Check if entity is inside a ticking chunk
|
||||
*/
|
||||
public boolean isTicking();
|
||||
+
|
||||
+ /**
|
||||
+ * Returns a set of {@link Player Players} within this entity's tracking range (players that can "see" this entity).
|
||||
+ *
|
||||
+ * @return players in tracking range
|
||||
+ */
|
||||
+ @NotNull Set<Player> getTrackedPlayers();
|
||||
// Paper end
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kennytv <jahnke.nassim@gmail.com>
|
||||
Date: Fri, 29 Jan 2021 15:13:11 +0100
|
||||
Subject: [PATCH] Add dropLeash variable to EntityUnleashEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 976dbf40292b10364f9e80bebe96ec9c4dfb657e..c375081e02925da6085a2d433bfc2c3719770f78 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1213,12 +1213,15 @@ public abstract class Mob extends LivingEntity {
|
||||
return InteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == player) {
|
||||
// CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||
- if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player).isCancelled()) {
|
||||
+ // Paper start - drop leash variable
|
||||
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, !player.getAbilities().instabuild);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Paper end
|
||||
((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
// CraftBukkit end
|
||||
- this.dropLeash(true, !player.getAbilities().instabuild);
|
||||
+ this.dropLeash(true, event.isDropLeash()); // Paper - drop leash variable
|
||||
return InteractionResult.sidedSuccess(this.level.isClientSide);
|
||||
} else {
|
||||
InteractionResult enuminteractionresult = this.checkAndHandleImportantInteractions(player, hand);
|
||||
@@ -1376,8 +1379,11 @@ public abstract class Mob extends LivingEntity {
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
||||
- this.dropLeash(true, true);
|
||||
+ // Paper start - drop leash variable
|
||||
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE, true);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ this.dropLeash(true, event.isDropLeash());
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1440,8 +1446,11 @@ public abstract class Mob extends LivingEntity {
|
||||
boolean flag1 = super.startRiding(entity, force);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
- this.dropLeash(true, true);
|
||||
+ // Paper start - drop leash variable
|
||||
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ this.dropLeash(true, event.isDropLeash());
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return flag1;
|
||||
@@ -1611,8 +1620,11 @@ public abstract class Mob extends LivingEntity {
|
||||
@Override
|
||||
protected void removeAfterChangingDimensions() {
|
||||
super.removeAfterChangingDimensions();
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
- this.dropLeash(true, false);
|
||||
+ // Paper start - drop leash variable
|
||||
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, false);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ this.dropLeash(true, event.isDropLeash());
|
||||
+ // Paper end
|
||||
this.getAllSlots().forEach((itemstack) -> {
|
||||
if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
index a884940cc576704951d42c6b0d00f5a319297c29..d16a7bab5495d58ea9e6811d4b507667cfa3d264 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
@@ -47,8 +47,11 @@ public abstract class PathfinderMob extends Mob {
|
||||
|
||||
if (this instanceof TamableAnimal && ((TamableAnimal) this).isInSittingPose()) {
|
||||
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
- this.dropLeash(true, true);
|
||||
+ // Paper start - drop leash variable
|
||||
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ this.dropLeash(true, event.isDropLeash());
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -56,8 +59,11 @@ public abstract class PathfinderMob extends Mob {
|
||||
|
||||
this.onLeashDistance(f);
|
||||
if (f > entity.level.paperConfig.maxLeashDistance) { // Paper
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
- this.dropLeash(true, true);
|
||||
+ // Paper start - drop leash variable
|
||||
+ EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ this.dropLeash(true, event.isDropLeash());
|
||||
+ // Paper end
|
||||
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
||||
} else if (f > 6.0F) {
|
||||
double d0 = (entity.getX() - this.getX()) / (double) f;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
||||
index b9b67134f02fd7484ed19905c9ae1f9b8a26ce26..c05f173b7642380900fdd77ce5d2c020468b5fc0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java
|
||||
@@ -123,11 +123,14 @@ public class LeashFenceKnotEntity extends HangingEntity {
|
||||
entityinsentient = (Mob) iterator.next();
|
||||
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
|
||||
// CraftBukkit start
|
||||
- if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player).isCancelled()) {
|
||||
+ // Paper start - drop leash variable
|
||||
+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player, !player.getAbilities().instabuild);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Paper end
|
||||
die = false;
|
||||
continue;
|
||||
}
|
||||
- entityinsentient.dropLeash(true, !player.getAbilities().instabuild); // false -> survival mode boolean
|
||||
+ entityinsentient.dropLeash(true, event.isDropLeash()); // false -> survival mode boolean // Paper - drop leash variable
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index db6b057eb6b0f08f7fcb998f8b646b757a98d3f6..33a8e174c4e3b3b5164157c90c8f5b5f9c6d8263 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1489,8 +1489,10 @@ public class CraftEventFactory {
|
||||
return itemInHand;
|
||||
}
|
||||
|
||||
- public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player) {
|
||||
- PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity());
|
||||
+ // Paper start - drop leash variable
|
||||
+ public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(Mob entity, net.minecraft.world.entity.player.Player player, boolean dropLeash) {
|
||||
+ PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), dropLeash);
|
||||
+ // Paper end
|
||||
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Beech Horn <beechhorn@gmail.com>
|
||||
Date: Fri, 14 Feb 2020 19:39:59 +0000
|
||||
Subject: [PATCH] Skip distance map update when spawning disabled.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 77a6a5883d7e9fba12d0a2c8f3e7f2565d4785b4..6d0c56e4071a990a3b168143e8ac73f8b5ed0379 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -974,7 +974,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
int l = this.distanceManager.getNaturalSpawnChunkCount();
|
||||
// Paper start - per player mob spawning
|
||||
NaturalSpawner.SpawnState spawnercreature_d; // moved down
|
||||
- if (this.chunkMap.playerMobDistanceMap != null) {
|
||||
+ if ((this.spawnFriendlies || this.spawnEnemies) && this.chunkMap.playerMobDistanceMap != null) { // don't update when animals and monsters are disabled
|
||||
// update distance map
|
||||
this.level.timings.playerMobDistanceMapUpdate.startTiming();
|
||||
this.chunkMap.playerMobDistanceMap.update(this.level.players, this.chunkMap.viewDistance);
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Yive <admin@yive.me>
|
||||
Date: Sun, 24 Jan 2021 08:55:19 -0800
|
||||
Subject: [PATCH] Reset shield blocking on dimension change
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 8608464c1d229625a10fd459427d8cc5e217789a..e1296bbc1f31f270053a47c21887efbad8718b72 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1142,6 +1142,11 @@ public class ServerPlayer extends Player {
|
||||
this.level.getCraftServer().getPluginManager().callEvent(changeEvent);
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (this.isBlocking()) {
|
||||
+ this.stopUsingItem();
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
return this;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Trigary <trigary0@gmail.com>
|
||||
Date: Mon, 25 Jan 2021 14:53:57 +0100
|
||||
Subject: [PATCH] add DragonEggFormEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
index f88719dede80c064f6210e078c435ffda32ecc1a..dec99c9d40705a89c395437d0d050f3ab36bc17b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
@@ -363,9 +363,24 @@ public class EndDragonFight {
|
||||
this.dragonEvent.setVisible(false);
|
||||
this.spawnExitPortal(true);
|
||||
this.spawnNewGateway();
|
||||
+ // Paper start - DragonEggFormEvent
|
||||
+ BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION);
|
||||
+ org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition);
|
||||
+ org.bukkit.craftbukkit.block.CraftBlockState eggState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.level, eggPosition);
|
||||
+ eggState.setData(Blocks.DRAGON_EGG.defaultBlockState());
|
||||
+ io.papermc.paper.event.block.DragonEggFormEvent eggEvent = new io.papermc.paper.event.block.DragonEggFormEvent(eggBlock, eggState,
|
||||
+ new org.bukkit.craftbukkit.boss.CraftDragonBattle(this));
|
||||
+ // Paper end - DragonEggFormEvent
|
||||
if (this.level.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg
|
||||
- this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState());
|
||||
+ // Paper start - DragonEggFormEvent
|
||||
+ //this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData());
|
||||
+ } else {
|
||||
+ eggEvent.setCancelled(true);
|
||||
+ }
|
||||
+ if (eggEvent.callEvent()) {
|
||||
+ eggEvent.getNewState().update(true);
|
||||
}
|
||||
+ // Paper end - DragonEggFormEvent
|
||||
|
||||
this.previouslyKilled = true;
|
||||
this.dragonKilled = true;
|
|
@ -1,55 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Tue, 11 Feb 2020 21:56:48 -0600
|
||||
Subject: [PATCH] EntityMoveEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d37b14523dd2a0e6412449001c7876bd27bf760e..f3976a53514249e64d91075ec2e620e4c7cef37f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1527,6 +1527,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
||||
+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
||||
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
|
||||
|
||||
this.profiler.push(() -> {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 073dbf69b5b58c4351110d28491e7feb2e47081c..c58b0de1cf1c51ceb0a0ecc145f4a98929521934 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -197,6 +197,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
public final UUID uuid;
|
||||
public boolean hasPhysicsEvent = true; // Paper
|
||||
+ public boolean hasEntityMoveEvent = false; // Paper
|
||||
public static Throwable getAddToWorldStackTrace(Entity entity) {
|
||||
return new Throwable(entity + " Added to world at " + new java.util.Date());
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index e3d8557733e20a51bb71d9c968f4f12cc3192624..8ce983822ab44ade6306b52cad352ad95f6d6bad 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3223,6 +3223,20 @@ public abstract class LivingEntity extends Entity {
|
||||
|
||||
this.pushEntities();
|
||||
this.level.getProfiler().pop();
|
||||
+ // Paper start
|
||||
+ if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) {
|
||||
+ if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
|
||||
+ Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO);
|
||||
+ Location to = new Location (this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone());
|
||||
+ if (!event.callEvent()) {
|
||||
+ absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch());
|
||||
+ } else if (!to.equals(event.getTo())) {
|
||||
+ absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
|
||||
this.hurt(DamageSource.DROWN, 1.0F);
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lukas81298 <lukas81298@gommehd.net>
|
||||
Date: Mon, 25 Jan 2021 14:37:57 +0100
|
||||
Subject: [PATCH] added option to disable pathfinding updates on block changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 3e694d8a28524f9ea6ba8f1947061b92bc15b13d..843878bb83dfebca8d3574c159c5e338f15104ac 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -807,5 +807,10 @@ public class PaperWorldConfig {
|
||||
private void enderDragonsDeathAlwaysPlacesDragonEgg() {
|
||||
enderDragonsDeathAlwaysPlacesDragonEgg = getBoolean("ender-dragons-death-always-places-dragon-egg", enderDragonsDeathAlwaysPlacesDragonEgg);
|
||||
}
|
||||
+
|
||||
+ public boolean updatePathfindingOnBlockUpdate = true;
|
||||
+ private void setUpdatePathfindingOnBlockUpdate() {
|
||||
+ updatePathfindingOnBlockUpdate = getBoolean("update-pathfinding-on-block-update", this.updatePathfindingOnBlockUpdate);
|
||||
+ }
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 09474f7e973563585e102cc839ab6842a3a10c0c..e0efad2395dd889430554074bbd9769957a72687 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1386,6 +1386,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
@Override
|
||||
public void sendBlockUpdated(BlockPos pos, BlockState oldState, BlockState newState, int flags) {
|
||||
this.getChunkSource().blockChanged(pos);
|
||||
+ if(this.paperConfig.updatePathfindingOnBlockUpdate) { // Paper - option to disable pathfinding updates
|
||||
VoxelShape voxelshape = oldState.getCollisionShape(this, pos);
|
||||
VoxelShape voxelshape1 = newState.getCollisionShape(this, pos);
|
||||
|
||||
@@ -1413,6 +1414,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
}
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,55 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 18 Jan 2021 20:45:25 -0500
|
||||
Subject: [PATCH] Inline shift direction fields
|
||||
|
||||
Removes a layer of indirection for EnumDirection.getAdjacent(X|Y|Z)(), which is in the
|
||||
critical section for much of the server, including the lighting engine.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
||||
index e8e9494f7f337ee91a56fbd299da015dcda4a81b..593d6251c75ec337175d08b85000239ba7da1af2 100644
|
||||
--- a/src/main/java/net/minecraft/core/Direction.java
|
||||
+++ b/src/main/java/net/minecraft/core/Direction.java
|
||||
@@ -62,6 +62,11 @@ public enum Direction implements StringRepresentable {
|
||||
}, (direction1, direction2) -> {
|
||||
throw new IllegalArgumentException("Duplicate keys");
|
||||
}, Long2ObjectOpenHashMap::new));
|
||||
+ // Paper start
|
||||
+ private final int adjX;
|
||||
+ private final int adjY;
|
||||
+ private final int adjZ;
|
||||
+ // Paper end
|
||||
|
||||
private Direction(int id, int idOpposite, int idHorizontal, String name, Direction.AxisDirection direction, Direction.Axis axis, Vec3i vector) {
|
||||
this.data3d = id;
|
||||
@@ -71,6 +76,11 @@ public enum Direction implements StringRepresentable {
|
||||
this.axis = axis;
|
||||
this.axisDirection = direction;
|
||||
this.normal = vector;
|
||||
+ // Paper start
|
||||
+ this.adjX = vector.getX();
|
||||
+ this.adjY = vector.getY();
|
||||
+ this.adjZ = vector.getZ();
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public static Direction[] orderedByNearest(Entity entity) {
|
||||
@@ -310,15 +320,15 @@ public enum Direction implements StringRepresentable {
|
||||
}
|
||||
|
||||
public int getStepX() {
|
||||
- return this.normal.getX();
|
||||
+ return this.adjX; // Paper
|
||||
}
|
||||
|
||||
public int getStepY() {
|
||||
- return this.normal.getY();
|
||||
+ return this.adjY; // Paper
|
||||
}
|
||||
|
||||
public int getStepZ() {
|
||||
- return this.normal.getZ();
|
||||
+ return this.adjZ; // Paper
|
||||
}
|
||||
|
||||
public Vector3f step() {
|
|
@ -1,44 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Wed, 20 Jan 2021 14:23:37 -0600
|
||||
Subject: [PATCH] Allow adding items to BlockDropItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 33a8e174c4e3b3b5164157c90c8f5b5f9c6d8263..2b2654ec04e8abca9db09d6257edf11099bb0d9b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -395,13 +395,30 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
public static void handleBlockDropItemEvent(Block block, BlockState state, ServerPlayer player, List<ItemEntity> items) {
|
||||
- BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), Lists.transform(items, (item) -> (org.bukkit.entity.Item) item.getBukkitEntity()));
|
||||
+ // Paper start
|
||||
+ List<Item> list = new ArrayList<>();
|
||||
+ for (ItemEntity item : items) {
|
||||
+ list.add((Item) item.getBukkitEntity());
|
||||
+ }
|
||||
+ BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), list);
|
||||
+ // Paper end
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
- for (ItemEntity item : items) {
|
||||
- item.level.addFreshEntity(item);
|
||||
+ // Paper start
|
||||
+ for (Item bukkit : list) {
|
||||
+ if (!bukkit.isValid()) {
|
||||
+ Entity item = ((org.bukkit.craftbukkit.entity.CraftItem) bukkit).getHandle();
|
||||
+ item.level.addFreshEntity(item);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (Item bukkit : list) {
|
||||
+ if (bukkit.isValid()) {
|
||||
+ bukkit.remove();
|
||||
+ }
|
||||
}
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aleksander Jagiello <themolkapl@gmail.com>
|
||||
Date: Sun, 24 Jan 2021 22:17:54 +0100
|
||||
Subject: [PATCH] Add getMainThreadExecutor to BukkitScheduler
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index a423970cf7c927ea8a1bf842aaa236d3cf2d54c2..cdefb2025eedea7e204d70d568adaf1c1ec4c03c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -655,4 +655,15 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
public BukkitTask runTaskTimerAsynchronously(Plugin plugin, BukkitRunnable task, long delay, long period) throws IllegalArgumentException {
|
||||
throw new UnsupportedOperationException("Use BukkitRunnable#runTaskTimerAsynchronously(Plugin, long, long)");
|
||||
}
|
||||
+
|
||||
+ // Paper start - add getMainThreadExecutor
|
||||
+ @Override
|
||||
+ public Executor getMainThreadExecutor(Plugin plugin) {
|
||||
+ Validate.notNull(plugin, "Plugin cannot be null");
|
||||
+ return command -> {
|
||||
+ Validate.notNull(command, "Command cannot be null");
|
||||
+ this.runTask(plugin, command);
|
||||
+ };
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ysl3000 <yannicklamprecht@live.de>
|
||||
Date: Sat, 24 Oct 2020 16:37:44 +0200
|
||||
Subject: [PATCH] living entity allow attribute registration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index cb9ed449ed96474d2115a3023ff0b7b298548071..9cbfda029782385d1a7987f5be46d450bd8a758e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -132,4 +132,12 @@ public class AttributeMap {
|
||||
}
|
||||
|
||||
}
|
||||
+
|
||||
+ // Paper - start
|
||||
+ public void registerAttribute(Attribute attributeBase) {
|
||||
+ AttributeInstance attributeModifiable = new AttributeInstance(attributeBase, AttributeInstance::getAttribute);
|
||||
+ attributes.put(attributeBase, attributeModifiable);
|
||||
+ }
|
||||
+ // Paper - end
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
index 46c313d581b9af6aa0a48f97ae3cc800a88535f2..07d700382fc356837045c46d320b7b69ad13af68 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
@@ -38,6 +38,14 @@ public class CraftAttributeMap implements Attributable {
|
||||
return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void registerAttribute(Attribute attribute) {
|
||||
+ Preconditions.checkArgument(attribute != null, "attribute");
|
||||
+ handle.registerAttribute(CraftAttributeMap.toMinecraft(attribute));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static net.minecraft.world.entity.ai.attributes.Attribute toMinecraft(Attribute attribute) {
|
||||
return net.minecraft.core.Registry.ATTRIBUTE.get(CraftNamespacedKey.toMinecraft(attribute.getKey()));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 7c8dba1c7d65b4b91eb5a83c029bc5b31750775f..88c0e80be343614947bfa3a14e08c5400a2d4ccc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -686,6 +686,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return this.getHandle().craftAttributes.getAttribute(attribute);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void registerAttribute(Attribute attribute) {
|
||||
+ getHandle().craftAttributes.registerAttribute(attribute);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void setAI(boolean ai) {
|
||||
if (this.getHandle() instanceof Mob) {
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Trigary <trigary0@gmail.com>
|
||||
Date: Fri, 5 Feb 2021 22:12:13 +0100
|
||||
Subject: [PATCH] fix dead slime setSize invincibility
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
||||
index 4d401403de2399919043651345eed91c11ac986f..3c5326b1b4b18365e06292eca447778442201176 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
||||
@@ -17,7 +17,7 @@ public class CraftSlime extends CraftMob implements Slime {
|
||||
|
||||
@Override
|
||||
public void setSize(int size) {
|
||||
- this.getHandle().setSize(size, true);
|
||||
+ this.getHandle().setSize(size, /* true */ getHandle().isAlive()); // Paper - fix dead slime setSize invincibility
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 10 Feb 2021 14:53:36 -0800
|
||||
Subject: [PATCH] Merchant#getRecipes should return an immutable list
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
|
||||
index 425c8de426cecc9919d03dc64325494104d1b294..fcd6574857f77d547fd8101c5ac097bc6306034c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java
|
||||
@@ -24,7 +24,7 @@ public class CraftMerchant implements Merchant {
|
||||
|
||||
@Override
|
||||
public List<MerchantRecipe> getRecipes() {
|
||||
- return Collections.unmodifiableList(Lists.transform(this.merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() {
|
||||
+ return com.google.common.collect.ImmutableList.copyOf(Lists.transform(this.merchant.getOffers(), new Function<net.minecraft.world.item.trading.MerchantOffer, MerchantRecipe>() { // Paper - javadoc says 'an immutable list of trades' - not 'an unmodifiable view of a list of trades'. fixes issue with setRecipes(getRecipes())
|
||||
@Override
|
||||
public MerchantRecipe apply(net.minecraft.world.item.trading.MerchantOffer recipe) {
|
||||
return recipe.asBukkit();
|
|
@ -1,233 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Josh Roy <10731363+JRoy@users.noreply.github.com>
|
||||
Date: Sat, 20 Feb 2021 13:09:59 -0500
|
||||
Subject: [PATCH] Add support for hex color codes in console
|
||||
|
||||
Converts upstream's hex color code legacy format into actual hex color codes in the console.
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 57edac376bcbd056fb8fc7f0a433e946bce4ff2e..f3db86346c5e7bf446707a746f3094f7f27e09c4 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -34,6 +34,7 @@ dependencies {
|
||||
Scanning takes about 1-2 seconds so adding this speeds up the server start.
|
||||
*/
|
||||
implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation
|
||||
+ annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for out hex color converter plugin
|
||||
// Paper end
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper
|
||||
implementation("org.apache.logging.log4j:log4j-api:2.14.1") // Paper
|
||||
diff --git a/src/main/java/io/papermc/paper/console/HexFormattingConverter.java b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a4315961b7a465fb4872a4d67e7c26d4b4ed1fb9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/console/HexFormattingConverter.java
|
||||
@@ -0,0 +1,178 @@
|
||||
+package io.papermc.paper.console;
|
||||
+
|
||||
+import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.config.Configuration;
|
||||
+import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
+import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||
+import org.apache.logging.log4j.core.pattern.*;
|
||||
+import org.apache.logging.log4j.util.PerformanceSensitive;
|
||||
+import org.apache.logging.log4j.util.PropertiesUtil;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import java.util.regex.Matcher;
|
||||
+import java.util.regex.Pattern;
|
||||
+
|
||||
+import static net.minecrell.terminalconsole.MinecraftFormattingConverter.KEEP_FORMATTING_PROPERTY;
|
||||
+
|
||||
+/**
|
||||
+ * Modified version of <a href="https://github.com/Minecrell/TerminalConsoleAppender/blob/master/src/main/java/net/minecrell/terminalconsole/MinecraftFormattingConverter.java">
|
||||
+ * TerminalConsoleAppender's MinecraftFormattingConverter</a> to support hex color codes using the md_5 &x&r&r&g&g&b&b format.
|
||||
+ */
|
||||
+@Plugin(name = "paperMinecraftFormatting", category = PatternConverter.CATEGORY)
|
||||
+@ConverterKeys({ "paperMinecraftFormatting" })
|
||||
+@PerformanceSensitive("allocation")
|
||||
+public final class HexFormattingConverter extends LogEventPatternConverter {
|
||||
+
|
||||
+ private static final boolean KEEP_FORMATTING = PropertiesUtil.getProperties().getBooleanProperty(KEEP_FORMATTING_PROPERTY);
|
||||
+
|
||||
+ private static final String ANSI_RESET = "\u001B[m";
|
||||
+
|
||||
+ private static final char COLOR_CHAR = '§';
|
||||
+ private static final String LOOKUP = "0123456789abcdefklmnor";
|
||||
+
|
||||
+ private static final String RGB_ANSI = "\u001B[38;2;%d;%d;%dm";
|
||||
+ private static final Pattern NAMED_PATTERN = Pattern.compile(COLOR_CHAR + "[0-9a-fk-orA-FK-OR]");
|
||||
+ private static final Pattern RGB_PATTERN = Pattern.compile(COLOR_CHAR + "x(" + COLOR_CHAR + "[0-9a-fA-F]){6}");
|
||||
+
|
||||
+ private static final String[] ansiCodes = new String[] {
|
||||
+ "\u001B[0;30m", // Black §0
|
||||
+ "\u001B[0;34m", // Dark Blue §1
|
||||
+ "\u001B[0;32m", // Dark Green §2
|
||||
+ "\u001B[0;36m", // Dark Aqua §3
|
||||
+ "\u001B[0;31m", // Dark Red §4
|
||||
+ "\u001B[0;35m", // Dark Purple §5
|
||||
+ "\u001B[0;33m", // Gold §6
|
||||
+ "\u001B[0;37m", // Gray §7
|
||||
+ "\u001B[0;30;1m", // Dark Gray §8
|
||||
+ "\u001B[0;34;1m", // Blue §9
|
||||
+ "\u001B[0;32;1m", // Green §a
|
||||
+ "\u001B[0;36;1m", // Aqua §b
|
||||
+ "\u001B[0;31;1m", // Red §c
|
||||
+ "\u001B[0;35;1m", // Light Purple §d
|
||||
+ "\u001B[0;33;1m", // Yellow §e
|
||||
+ "\u001B[0;37;1m", // White §f
|
||||
+ "\u001B[5m", // Obfuscated §k
|
||||
+ "\u001B[21m", // Bold §l
|
||||
+ "\u001B[9m", // Strikethrough §m
|
||||
+ "\u001B[4m", // Underline §n
|
||||
+ "\u001B[3m", // Italic §o
|
||||
+ ANSI_RESET, // Reset §r
|
||||
+ };
|
||||
+
|
||||
+ private final boolean ansi;
|
||||
+ private final List<PatternFormatter> formatters;
|
||||
+
|
||||
+ /**
|
||||
+ * Construct the converter.
|
||||
+ *
|
||||
+ * @param formatters The pattern formatters to generate the text to manipulate
|
||||
+ * @param strip If true, the converter will strip all formatting codes
|
||||
+ */
|
||||
+ protected HexFormattingConverter(List<PatternFormatter> formatters, boolean strip) {
|
||||
+ super("paperMinecraftFormatting", null);
|
||||
+ this.formatters = formatters;
|
||||
+ this.ansi = !strip;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void format(LogEvent event, StringBuilder toAppendTo) {
|
||||
+ int start = toAppendTo.length();
|
||||
+ //noinspection ForLoopReplaceableByForEach
|
||||
+ for (int i = 0, size = formatters.size(); i < size; i++) {
|
||||
+ formatters.get(i).format(event, toAppendTo);
|
||||
+ }
|
||||
+
|
||||
+ if (KEEP_FORMATTING || toAppendTo.length() == start) {
|
||||
+ // Skip replacement if disabled or if the content is empty
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ boolean useAnsi = ansi && TerminalConsoleAppender.isAnsiSupported();
|
||||
+ String content = toAppendTo.substring(start);
|
||||
+ content = useAnsi ? convertRGBColors(content) : stripRGBColors(content);
|
||||
+ format(content, toAppendTo, start, useAnsi);
|
||||
+ }
|
||||
+
|
||||
+ private static String convertRGBColors(String input) {
|
||||
+ Matcher matcher = RGB_PATTERN.matcher(input);
|
||||
+ StringBuffer buffer = new StringBuffer();
|
||||
+ while (matcher.find()) {
|
||||
+ String s = matcher.group().replace(String.valueOf(COLOR_CHAR), "").replace('x', '#');
|
||||
+ int hex = Integer.decode(s);
|
||||
+ int red = (hex >> 16) & 0xFF;
|
||||
+ int green = (hex >> 8) & 0xFF;
|
||||
+ int blue = hex & 0xFF;
|
||||
+ String replacement = String.format(RGB_ANSI, red, green, blue);
|
||||
+ matcher.appendReplacement(buffer, replacement);
|
||||
+ }
|
||||
+ matcher.appendTail(buffer);
|
||||
+ return buffer.toString();
|
||||
+ }
|
||||
+
|
||||
+ private static String stripRGBColors(String input) {
|
||||
+ Matcher matcher = RGB_PATTERN.matcher(input);
|
||||
+ StringBuffer buffer = new StringBuffer();
|
||||
+ while (matcher.find()) {
|
||||
+ matcher.appendReplacement(buffer, "");
|
||||
+ }
|
||||
+ matcher.appendTail(buffer);
|
||||
+ return buffer.toString();
|
||||
+ }
|
||||
+
|
||||
+ static void format(String content, StringBuilder result, int start, boolean ansi) {
|
||||
+ int next = content.indexOf(COLOR_CHAR);
|
||||
+ int last = content.length() - 1;
|
||||
+ if (next == -1 || next == last) {
|
||||
+ result.setLength(start);
|
||||
+ result.append(content);
|
||||
+ if (ansi) {
|
||||
+ result.append(ANSI_RESET);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ Matcher matcher = NAMED_PATTERN.matcher(content);
|
||||
+ StringBuffer buffer = new StringBuffer();
|
||||
+ while (matcher.find()) {
|
||||
+ int format = LOOKUP.indexOf(Character.toLowerCase(matcher.group().charAt(1)));
|
||||
+ if (format != -1) {
|
||||
+ matcher.appendReplacement(buffer, ansi ? ansiCodes[format] : "");
|
||||
+ }
|
||||
+ }
|
||||
+ matcher.appendTail(buffer);
|
||||
+
|
||||
+ result.setLength(start);
|
||||
+ result.append(buffer.toString());
|
||||
+ if (ansi) {
|
||||
+ result.append(ANSI_RESET);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a new instance of the {@link HexFormattingConverter} with the
|
||||
+ * specified options.
|
||||
+ *
|
||||
+ * @param config The current configuration
|
||||
+ * @param options The pattern options
|
||||
+ * @return The new instance
|
||||
+ *
|
||||
+ * @see HexFormattingConverter
|
||||
+ */
|
||||
+ public static HexFormattingConverter newInstance(Configuration config, String[] options) {
|
||||
+ if (options.length < 1 || options.length > 2) {
|
||||
+ LOGGER.error("Incorrect number of options on paperMinecraftFormatting. Expected at least 1, max 2 received " + options.length);
|
||||
+ return null;
|
||||
+ }
|
||||
+ if (options[0] == null) {
|
||||
+ LOGGER.error("No pattern supplied on paperMinecraftFormatting");
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ PatternParser parser = PatternLayout.createPatternParser(config);
|
||||
+ List<PatternFormatter> formatters = parser.parse(options[0]);
|
||||
+ boolean strip = options.length > 1 && "strip".equals(options[1]);
|
||||
+ return new HexFormattingConverter(formatters, strip);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
||||
index 1a05d23ff886b015fb9396f119822c678a47ec6f..2e421eaac80cf251b32e0bb504dd54a73edf4986 100644
|
||||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -6,21 +6,21 @@
|
||||
</Queue>
|
||||
<TerminalConsole name="TerminalConsole">
|
||||
<PatternLayout>
|
||||
- <LoggerNamePatternSelector defaultPattern="%highlightError{[%d{HH:mm:ss} %level]: [%logger] %minecraftFormatting{%msg}%n%xEx{full}}">
|
||||
+ <LoggerNamePatternSelector defaultPattern="%highlightError{[%d{HH:mm:ss} %level]: [%logger] %paperMinecraftFormatting{%msg}%n%xEx{full}}">
|
||||
<!-- Log root, Minecraft, Mojang and Bukkit loggers without prefix -->
|
||||
<!-- Disable prefix for various plugins that bypass the plugin logger -->
|
||||
<PatternMatch key=",net.minecraft.,Minecraft,com.mojang.,com.sk89q.,ru.tehkode.,Minecraft.AWE"
|
||||
- pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx{full}}" />
|
||||
+ pattern="%highlightError{[%d{HH:mm:ss} %level]: %paperMinecraftFormatting{%msg}%n%xEx{full}}" />
|
||||
</LoggerNamePatternSelector>
|
||||
</PatternLayout>
|
||||
</TerminalConsole>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout>
|
||||
- <LoggerNamePatternSelector defaultPattern="[%d{HH:mm:ss}] [%t/%level]: [%logger] %minecraftFormatting{%msg}{strip}%n%xEx{full}">
|
||||
+ <LoggerNamePatternSelector defaultPattern="[%d{HH:mm:ss}] [%t/%level]: [%logger] %paperMinecraftFormatting{%msg}{strip}%n%xEx{full}">
|
||||
<!-- Log root, Minecraft, Mojang and Bukkit loggers without prefix -->
|
||||
<!-- Disable prefix for various plugins that bypass the plugin logger -->
|
||||
<PatternMatch key=",net.minecraft.,Minecraft,com.mojang.,com.sk89q.,ru.tehkode.,Minecraft.AWE"
|
||||
- pattern="[%d{HH:mm:ss}] [%t/%level]: %minecraftFormatting{%msg}{strip}%n%xEx{full}" />
|
||||
+ pattern="[%d{HH:mm:ss}] [%t/%level]: %paperMinecraftFormatting{%msg}{strip}%n%xEx{full}" />
|
||||
</LoggerNamePatternSelector>
|
||||
</PatternLayout>
|
||||
<Policies>
|
|
@ -1,29 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Tom <cryptite@gmail.com>
|
||||
Date: Fri, 26 Feb 2021 16:24:25 -0600
|
||||
Subject: [PATCH] Expose Tracked Players
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 986f045a2e6a040c6e2aab7420c8cb2d4ac3a726..ee50ea695585639d0ff184b675f3fb3b205b9f86 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1263,5 +1263,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public boolean isTicking() {
|
||||
return getHandle().isTicking();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Set<org.bukkit.entity.Player> getTrackedPlayers() {
|
||||
+ if (this.entity.tracker == null) {
|
||||
+ return java.util.Collections.emptySet();
|
||||
+ }
|
||||
+
|
||||
+ Set<org.bukkit.entity.Player> set = new java.util.HashSet<>(this.entity.tracker.seenBy.size());
|
||||
+ for (net.minecraft.server.network.ServerPlayerConnection connection : this.entity.tracker.seenBy) {
|
||||
+ set.add(connection.getPlayer().getBukkitEntity().getPlayer());
|
||||
+ }
|
||||
+ return set;
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Bjarne Koll <lynxplay101@gmail.com>
|
||||
Date: Wed, 3 Mar 2021 12:48:48 +0100
|
||||
Subject: [PATCH] Remove streams from SensorNearest
|
||||
|
||||
The behavioural nearby sensors are validated every tick on the entities
|
||||
that registered the respective sensors and are therefore a good subject
|
||||
to performance improvements.
|
||||
|
||||
More specifically this commit replaces the Stream#filter usage with
|
||||
ArrayList#removeIf as the removeIf method on an array list is heavily
|
||||
optimized towards a single internal array re-allocation without any
|
||||
further overhead on the removeIf call.
|
||||
|
||||
The only negative of this change is the rather agressive diff these
|
||||
patches introduce as the methods are basically being reimplemented
|
||||
compared to the previous stream-based implementation.
|
||||
|
||||
See: https://nipafx.dev/java-stream-performance/
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
|
||||
index 7680c269c2fe0cf2a51d0ebeb34624181826d578..49f3b25d28072b61f5cc97260df61df892a58714 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
|
||||
@@ -28,11 +28,15 @@ public class NearestItemSensor extends Sensor<Mob> {
|
||||
return true;
|
||||
});
|
||||
list.sort(Comparator.comparingDouble(entity::distanceToSqr));
|
||||
- Optional<ItemEntity> optional = list.stream().filter((itemEntity) -> {
|
||||
- return entity.wantsToPickUp(itemEntity.getItem());
|
||||
- }).filter((itemEntity) -> {
|
||||
- return itemEntity.closerThan(entity, 9.0D);
|
||||
- }).filter(entity::hasLineOfSight).findFirst();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional);
|
||||
+ // Paper start - remove streams in favour of lists
|
||||
+ ItemEntity nearest = null;
|
||||
+ for (ItemEntity entityItem : list) {
|
||||
+ if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 9.0D) && entity.hasLineOfSight(entityItem)) {
|
||||
+ nearest = entityItem;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, Optional.ofNullable(nearest));
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
|
||||
index 66c90013e52170a657b1a5dbdb99748a19fe55e8..ffd83db0a419ab589e89feeddd3fb038d6ed5839 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java
|
||||
@@ -21,9 +21,11 @@ public class NearestLivingEntitySensor extends Sensor<LivingEntity> {
|
||||
list.sort(Comparator.comparingDouble(entity::distanceToSqr));
|
||||
Brain<?> brain = entity.getBrain();
|
||||
brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list);
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, list.stream().filter((livingEntity2) -> {
|
||||
- return isEntityTargetable(entity, livingEntity2);
|
||||
- }).collect(Collectors.toList()));
|
||||
+ // Paper start - remove streams in favour of lists
|
||||
+ List<LivingEntity> visibleMobs = new java.util.ArrayList<>(list);
|
||||
+ visibleMobs.removeIf(otherEntityLiving -> !Sensor.isEntityTargetable(entity, otherEntityLiving));
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, visibleMobs);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
index b51574548b370f8a86d27835e9888ce1cd1d18be..457ea75137b8b02dc32bf1769ae8d57c470da470 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
@@ -21,18 +21,25 @@ public class PlayerSensor extends Sensor<LivingEntity> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel world, LivingEntity entity) {
|
||||
- List<Player> list = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((serverPlayer) -> {
|
||||
- return entity.closerThan(serverPlayer, 16.0D);
|
||||
- }).sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList());
|
||||
+ // Paper start - remove streams in favour of lists
|
||||
+ List<Player> players = new java.util.ArrayList<>(world.players());
|
||||
+ players.removeIf(player -> !EntitySelector.NO_SPECTATORS.test(player) || !entity.closerThan(player, 16.0D)); // Paper - removeIf only re-allocates once compared to iterator
|
||||
Brain<?> brain = entity.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list);
|
||||
- List<Player> list2 = list.stream().filter((player) -> {
|
||||
- return isEntityTargetable(entity, player);
|
||||
- }).collect(Collectors.toList());
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list2.isEmpty() ? null : list2.get(0));
|
||||
- Optional<Player> optional = list2.stream().filter((player) -> {
|
||||
- return isEntityAttackable(entity, player);
|
||||
- }).findFirst();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, optional);
|
||||
+
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players);
|
||||
+
|
||||
+ Player nearest = null, nearestTargetable = null;
|
||||
+ for (Player player : players) {
|
||||
+ if (Sensor.isEntityTargetable(entity, player)) {
|
||||
+ if (nearest == null) nearest = player;
|
||||
+ if (Sensor.isEntityAttackable(entity, player)) {
|
||||
+ nearestTargetable = player;
|
||||
+ break; // Both variables are assigned, no reason to loop further
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, nearest);
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, nearestTargetable);
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue