more patches (#5808)

This commit is contained in:
Jake Potrebic 2021-06-12 12:30:37 -07:00 committed by GitHub
parent d7e184d055
commit 716a3139b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
73 changed files with 515 additions and 605 deletions

View File

@ -9,7 +9,7 @@ In Offline Mode, will return an Offline UUID
This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index f5d3a7370390871d1b6075f32846d1a942b05b7f..2d7f8e128e23934a8fe26baf19198b7ffc8447bb 100644 index c9f00ffe05c8624619b23ad22cf61233cede440e..1f4532e60abe62b88472a9bb0ef8d1af1f921220 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -504,6 +504,20 @@ public final class Bukkit { @@ -504,6 +504,20 @@ public final class Bukkit {
@ -34,7 +34,7 @@ index f5d3a7370390871d1b6075f32846d1a942b05b7f..2d7f8e128e23934a8fe26baf19198b7f
* Gets the plugin manager for interfacing with plugins. * Gets the plugin manager for interfacing with plugins.
* *
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 38d138b217734e598581ed14065ff2015135ee9a..01657abaff86cf7bb3ffb857024c5032781b8660 100644 index f2448c6dc8ef64393127a13c33eb14b0d5cd92c0..ca4e2d3b27f629e0d5e672fc915a5d03f0c0581d 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -429,6 +429,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -429,6 +429,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add method to open already placed sign
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
index d212d5123b6294f7873d72f125505a006c290b05..7430bc85301d0fcb34c6035fbe08ae245c76e043 100644 index 8ba6a59066234b834aedb0fb414ee7391aa2ac18..2e86d4c9ee85cf0f9096472b8c3d131522181215 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java --- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -461,6 +461,14 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder @@ -461,6 +461,14 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder

View File

@ -74,7 +74,7 @@ index 58313929f81509030216a0e5e3869da63e11108e..6cf05fed701c67a2c797a4e0839c7958
/** /**
* Checks if this player is whitelisted or not * Checks if this player is whitelisted or not
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 6769330f336afcd5f26c0f7286defa00bead543c..88fd4cdeaad4d27f414c6b268022cdedf73492e7 100644 index 3ae4d670059f80bd057870a37f4025261e397dfa..257bf4a75393d1e25839bcae0ca5551ee832c627 100644
--- a/src/main/java/org/bukkit/entity/Player.java --- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java
@@ -5,6 +5,10 @@ import java.util.UUID; @@ -5,6 +5,10 @@ import java.util.UUID;

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Additional world.getNearbyEntities API's
Provides more methods to get nearby entities, and filter by types and predicates Provides more methods to get nearby entities, and filter by types and predicates
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 0f86a9c67797fd662cbbfdb808789bcab95caba4..cae848ce698337d0b254bd48938abfc1e68ad561 100644 index 8804be419520859355b69660e6f3166d1aa8b1ea..6cc9c7fc913f229c4869a976e73253acb74fcda3 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
@ -277,7 +277,7 @@ index 0f86a9c67797fd662cbbfdb808789bcab95caba4..cae848ce698337d0b254bd48938abfc1
* Get a list of all players in this World * Get a list of all players in this World
* *
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
index a40b57edb1aeff71fc0b9767d410950da5c06283..184d9462ebbc500d8b81aaf14fe138d247bf2470 100644 index d512c23ad0275061593d99f005c72292dbb07e81..c9af02b0f62b3d18da1e91d1ea02ce0864fc60b9 100644
--- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java --- a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
@@ -42,8 +42,7 @@ public class AsyncPlayerPreLoginEvent extends Event { @@ -42,8 +42,7 @@ public class AsyncPlayerPreLoginEvent extends Event {

View File

@ -53,7 +53,7 @@ index 41e26451fe12d8e6e0ef73c85731b24b4e3f200c..86cc5025ad98f7a752c51713b7cd6a39
* Gets a {@link Permission} from its fully qualified name * Gets a {@link Permission} from its fully qualified name
* *
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 8b33d914d29897c0276f9e2e7ce83bd2c316d5e2..a7393d2830b95d7167121b02066a3f357cee6085 100644 index 2d27dfb859c312d46a14d0356c7c3f227e965a67..892ec4b43cc97a235df0819d30391a8a3770cbcb 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -492,17 +492,28 @@ public final class SimplePluginManager implements PluginManager { @@ -492,17 +492,28 @@ public final class SimplePluginManager implements PluginManager {

View File

@ -6,7 +6,7 @@ Subject: [PATCH] ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item Allows you to determine how long it takes to use a usable/consumable item
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index 82bd3e6701dbd7df9f0f8c3801c5ae1baba4eec5..f41701e6374ca23eca4bdb092e385053a12eb718 100644 index e8783b0116f4efd5447a5f6f260506000983ffd2..9fee2f157ac5149cd65136bf8468deaca410fbf4 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java --- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -636,5 +636,13 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor @@ -636,5 +636,13 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor

View File

@ -106,7 +106,7 @@ index 4cf22afc3c1f1cc19b6e5350043431215908a612..af2ee43f2c5133668c18710f526a107d
* Returns a list of entities within a bounding box centered around a Location. * Returns a list of entities within a bounding box centered around a Location.
* *
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 05643d0f2bf2cb2dedb0a2ad693b2121565d3f1f..c7cdbc36f96a8ee9eaac2a2145afbfc76bc38cc9 100644 index ca2b1cbff153c53ec9182e44a1979350bacd695b..53407b999258967a116241ab7d791ac52a344b80 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1442,6 +1442,88 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @@ -1442,6 +1442,88 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad

View File

@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack API additions for quantity/flags/lore
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
index f41701e6374ca23eca4bdb092e385053a12eb718..07fd8a495828ff79239359c736c425c4902543a4 100644 index 9fee2f157ac5149cd65136bf8468deaca410fbf4..686e2a0b9fe061816b41435ef2337870dbdca8e5 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java --- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -2,7 +2,9 @@ package org.bukkit.inventory; @@ -2,7 +2,9 @@ package org.bukkit.inventory;

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add World.getEntity(UUID) API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index c7cdbc36f96a8ee9eaac2a2145afbfc76bc38cc9..edf136ef50c9cdd8ccea2e35508e4464c3de99bd 100644 index 53407b999258967a116241ab7d791ac52a344b80..a7bd869fb5b8e35274eee0d8dae9dd6fe3c1c540 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -946,6 +946,17 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad @@ -946,6 +946,17 @@ public interface World extends PluginMessageRecipient, Metadatable, net.kyori.ad

View File

@ -7,7 +7,7 @@ Allows you to determine why an inventory was closed, enabling plugin developers
to "confirm" things based on if it was player triggered close or not. to "confirm" things based on if it was player triggered close or not.
diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java
index 7430bc85301d0fcb34c6035fbe08ae245c76e043..3418133d07250a7fd50caad8d97924b86fb30bad 100644 index 2e86d4c9ee85cf0f9096472b8c3d131522181215..3cf96a3656d3366952f15744c9970e752e97be9a 100644
--- a/src/main/java/org/bukkit/entity/HumanEntity.java --- a/src/main/java/org/bukkit/entity/HumanEntity.java
+++ b/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java
@@ -153,6 +153,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder @@ -153,6 +153,15 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder

View File

@ -6,16 +6,18 @@ Subject: [PATCH] Fix Dragon Server Crashes
If the dragon tries to find "ground" and hits a hole, or off edge, If the dragon tries to find "ground" and hits a hole, or off edge,
it will infinitely keep looking for non air and eventually crash. it will infinitely keep looking for non air and eventually crash.
Fixed in 1.15
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
index 5e701b02e464889fe433b08018d13e63b24506eb..0c2a5f5c4d7d7516793eba20205b5703fe1450d5 100644 index df44bfce8cc492cd901dfa86331b9be7f1e13837..9eca797b4db96c5f2bb93d260f8e84077d92854a 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java
@@ -63,7 +63,7 @@ public class DragonSittingFlamingPhase extends AbstractDragonSittingPhase { @@ -64,7 +64,7 @@ public class DragonSittingFlamingPhase extends AbstractDragonSittingPhase {
double d3 = d2; double h = g;
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(d0, d2, d1); BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(d, g, e);
- while (this.dragon.level.isEmptyBlock(blockposition_mutableblockposition)) { - while(this.dragon.level.isEmptyBlock(mutableBlockPos)) {
+ while (this.dragon.level.isEmptyBlock(blockposition_mutableblockposition ) && d2 > 0) { // Paper + while(this.dragon.level.isEmptyBlock(mutableBlockPos) && g > 0) { // Paper
--d3; --h;
if (d3 < 0.0D) { if (h < 0.0D) {
d3 = d2; h = g;

View File

@ -1,32 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 10 Mar 2018 16:33:15 -0500
Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks
1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded.
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
index ae2f5acd008d5d7163b56cb4a2d29354299959ca..99843f1ca4737d40ae0626fce931c97bbf5ab81d 100644
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
@@ -40,7 +40,8 @@ public class FrostedIceBlock extends IceBlock {
Direction enumdirection = aenumdirection[j];
blockposition_mutableblockposition.setWithOffset((Vec3i) pos, enumdirection);
- BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition);
+ BlockState iblockdata1 = world.getTypeIfLoaded(blockposition_mutableblockposition); // Paper
+ if (iblockdata1 == null) { continue; } // Paper
if (iblockdata1.is((Block) this) && !this.slightlyMelt(iblockdata1, (Level) world, blockposition_mutableblockposition)) {
world.getBlockTicks().scheduleTick(blockposition_mutableblockposition, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay
@@ -83,7 +84,9 @@ public class FrostedIceBlock extends IceBlock {
Direction enumdirection = aenumdirection[l];
blockposition_mutableblockposition.setWithOffset((Vec3i) pos, enumdirection);
- if (world.getBlockState(blockposition_mutableblockposition).is((Block) this)) {
+ // Paper start
+ BlockState type = world.getTypeIfLoaded(blockposition_mutableblockposition);
+ if (type != null && type.is((Block) this)) { // Paper end
++j;
if (j >= maxNeighbors) {
return false;

View File

@ -1,31 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 0x22 <0x22@futureclient.net>
Date: Thu, 26 Apr 2018 04:41:11 -0400
Subject: [PATCH] Fix exploit that allowed colored signs to be created
diff --git a/src/main/java/net/minecraft/SharedConstants.java b/src/main/java/net/minecraft/SharedConstants.java
index a70c3d25930e7414fc9e897de8d2e0c12f11c0e4..04b8783417bbcd826d6d1c302551fbad9c48bd01 100644
--- a/src/main/java/net/minecraft/SharedConstants.java
+++ b/src/main/java/net/minecraft/SharedConstants.java
@@ -20,6 +20,7 @@ public class SharedConstants {
return chr != 167 && chr >= ' ' && chr != 127;
}
+ public static String filterAllowedChatCharacters(String input) { return filterText(input); } // Paper - OBFHELPER
public static String filterText(String s) {
StringBuilder stringbuilder = new StringBuilder();
char[] achar = s.toCharArray();
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 8d0c44b6c2c99d5161c5d4b79209b79ff6db75e4..fb36aa08cd2fbe3f7262dccb8cf0f7cae55aea9c 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2786,7 +2786,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
List<net.kyori.adventure.text.Component> lines = new java.util.ArrayList<>();
for (int i = 0; i < list.size(); ++i) {
- lines.add(net.kyori.adventure.text.Component.text(list.get(i)));
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(list.get(i)))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
}
SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines);
this.craftServer.getPluginManager().callEvent(event);

View File

@ -1,46 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 1 May 2018 20:18:54 -0400
Subject: [PATCH] EndermanAttackPlayerEvent
Allow control over whether or not an enderman aggros a player.
This allows you to override/extend the pumpkin/stare logic.
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 1981c08af85b16d45531ffae4fe790bb31edec04..d190b58bea310f4006ea3deaf0d42c502d441284 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -221,20 +221,28 @@ public class EnderMan extends Monster implements NeutralMob {
this.readPersistentAngerSaveData((ServerLevel) this.level, tag);
}
+ // Paper start - OBFHELPER - ok not really, but verify this on updates
private boolean isLookingAtMe(Player player) {
- ItemStack itemstack = (ItemStack) player.inventory.armor.get(3);
+ boolean shouldAttack = g_real(player);
+ com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
+ event.setCancelled(!shouldAttack);
+ return event.callEvent();
+ }
+ private boolean g_real(Player entityhuman) {
+ // Paper end
+ ItemStack itemstack = (ItemStack) entityhuman.inventory.armor.get(3);
if (itemstack.getItem() == Blocks.CARVED_PUMPKIN.asItem()) {
return false;
} else {
- Vec3 vec3d = player.getViewVector(1.0F).normalize();
- Vec3 vec3d1 = new Vec3(this.getX() - player.getX(), this.getEyeY() - player.getEyeY(), this.getZ() - player.getZ());
+ Vec3 vec3d = entityhuman.getViewVector(1.0F).normalize();
+ Vec3 vec3d1 = new Vec3(this.getX() - entityhuman.getX(), this.getEyeY() - entityhuman.getEyeY(), this.getZ() - entityhuman.getZ());
double d0 = vec3d1.length();
vec3d1 = vec3d1.normalize();
double d1 = vec3d.dot(vec3d1);
- return d1 > 1.0D - 0.025D / d0 ? player.canSee(this) : false;
+ return d1 > 1.0D - 0.025D / d0 ? entityhuman.canSee(this) : false;
}
}

View File

@ -1,37 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 23:00:29 -0400
Subject: [PATCH] ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index a0815c0d7f68f345dc48c73b8253de637c7a3e0f..34187197efd5ceff0503682dc6ce313220ca916f 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -604,6 +604,7 @@ public final class ItemStack {
this.getItem().onCraftedBy(this, world, player);
}
+ public int getItemUseMaxDuration() { return getUseDuration(); } // Paper - OBFHELPER
public int getUseDuration() {
return this.getItem().getUseDuration(this);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 5f0ccdeb8565505278caa591f7390047eab49cf4..44caf00330e4f4f74745973dbe709980f0b61269 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -173,6 +173,13 @@ public final class CraftItemStack extends ItemStack {
return (handle == null) ? Material.AIR.getMaxStackSize() : handle.getItem().getMaxStackSize();
}
+ // Paper start
+ @Override
+ public int getMaxItemUseDuration() {
+ return handle == null ? 0 : handle.getItemUseMaxDuration();
+ }
+ // Paper end
+
@Override
public void addUnsafeEnchantment(Enchantment ench, int level) {
Validate.notNull(ench, "Cannot add null enchantment");

View File

@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 Jun 2018 01:18:49 -0400
Subject: [PATCH] Unset Ignited flag on cancel of Explosion Event
Otherwise the creeper infinite explodes
diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
index 8f8d0a23d011936150854a0606be3d63b18c57af..d9b5cf8ac01289801ded01d928fa7ead96551be5 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -47,7 +47,7 @@ public class Creeper extends Monster {
private static final EntityDataAccessor<Integer> DATA_SWELL_DIR = SynchedEntityData.defineId(Creeper.class, EntityDataSerializers.INT);
private static final EntityDataAccessor<Boolean> DATA_IS_POWERED = SynchedEntityData.defineId(Creeper.class, EntityDataSerializers.BOOLEAN);
- private static final EntityDataAccessor<Boolean> DATA_IS_IGNITED = SynchedEntityData.defineId(Creeper.class, EntityDataSerializers.BOOLEAN);
+ private static final EntityDataAccessor<Boolean> DATA_IS_IGNITED = SynchedEntityData.defineId(Creeper.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor<Boolean> isIgnitedDW = DATA_IS_IGNITED; // Paper OBFHELPER
private int oldSwell;
public int swell; // PAIL
public int maxSwell = 30;
@@ -252,6 +252,7 @@ public class Creeper extends Monster {
this.spawnLingeringCloud();
} else {
swell = 0;
+ this.entityData.set(isIgnitedDW, Boolean.valueOf(false)); // Paper
}
// CraftBukkit end
}

View File

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 15 Jun 2013 19:51:17 -0400
Subject: [PATCH] Improve EntityShootBowEvent
Adds missing call to Illagers and also adds Arrow ItemStack to skeltons
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
index e8ad820b11dd1b89e442bb057d5761c90c4b1923..76027a7c9615495af64102744e264d7ba7c9b87e 100644
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -197,7 +197,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4));
// CraftBukkit start
- org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true);
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getOriginalItemStack(), entityarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper
if (event.isCancelled()) {
event.getProjectile().remove();
return;
diff --git a/src/main/java/net/minecraft/world/entity/monster/Illusioner.java b/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
index ab8c41e72c15ee9e5256eba2ba2681a33ce8a8d9..2d07e9cf4c84bc32a7624f65173c4e8a6dc07165 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
@@ -171,8 +171,18 @@ public class Illusioner extends SpellcasterIllager implements RangedAttackMob {
double d3 = (double) Mth.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4));
+ // Paper start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getOriginalItemStack(), entityarrow, target.getUsedItemHand(), 0.8F, true);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ this.level.addFreshEntity(entityarrow);
+ }
this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.level.addFreshEntity(entityarrow);
+ // Paper end
}
class IllusionerBlindnessSpellGoal extends SpellcasterIllager.SpellcasterUseSpellGoal {

View File

@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Jun 2018 00:21:28 -0400
Subject: [PATCH] LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 04489a915d11ba970a5188a5a913432ab4ef9faa..205c639d26652befebae925fc6e40976c370710f 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -209,7 +209,7 @@ public abstract class LivingEntity extends Entity {
private float speed;
private int noJumpDelay;
private float absorptionAmount;
- protected ItemStack useItem;
+ public ItemStack useItem; // Paper - public
protected int useItemRemaining;
protected int fallFlyTicks;
private BlockPos lastPos;
@@ -3291,10 +3291,12 @@ public abstract class LivingEntity extends Entity {
return this.useItem;
}
+ public int getItemUseRemainingTime() { return this.getUseItemRemainingTicks(); } // Paper - OBFHELPER
public int getUseItemRemainingTicks() {
return this.useItemRemaining;
}
+ public int getHandRaisedTime() { return this.getTicksUsingItem(); } // Paper - OBFHELPER
public int getTicksUsingItem() {
return this.isUsingItem() ? this.useItem.getUseDuration() - this.getUseItemRemainingTicks() : 0;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 663887d9aecc2823fe7d02a9b108a291cd27102c..6dd7a722e10a2727f68318b880f2726bb816f198 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -709,5 +709,30 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setShieldBlockingDelay(int delay) {
getHandle().setShieldBlockingDelay(delay);
}
+
+ @Override
+ public ItemStack getActiveItem() {
+ return getHandle().useItem.asBukkitMirror();
+ }
+
+ @Override
+ public int getItemUseRemainingTime() {
+ return getHandle().getItemUseRemainingTime();
+ }
+
+ @Override
+ public int getHandRaisedTime() {
+ return getHandle().getHandRaisedTime();
+ }
+
+ @Override
+ public boolean isHandRaised() {
+ return getHandle().isUsingItem();
+ }
+
+ @Override
+ public org.bukkit.inventory.EquipmentSlot getHandRaised() {
+ return getHandle().getUsedItemHand() == net.minecraft.world.InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
+ }
// Paper end
}

View File

@ -6,19 +6,6 @@ Subject: [PATCH] Provide E/TE/Chunk count stat methods
Provides counts without the ineffeciency of using .getEntities().size() Provides counts without the ineffeciency of using .getEntities().size()
which creates copy of the collections. which creates copy of the collections.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8323ddb363f49d266dd95f11241a30a9a27250aa..2cd34f326f374e3ad46a4eea8c84be326cd489a0 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -173,7 +173,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0);
private static final Logger LOGGER = LogManager.getLogger();
private static final int EMPTY_TIME_NO_TICK = 300;
- final List<ServerPlayer> players;
+ final List<ServerPlayer> players; public final int getPlayerListSize() { return this.players.size(); } // Paper
public final ServerChunkCache chunkSource; // Paper - public
private final MinecraftServer server;
public final PrimaryLevelData serverLevelData; // CraftBukkit - type
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 52d80086deff664fcfd8952b7cabbfa1f48ad131..a86b5272c0ac4dd64f796f7fd025c7a34a5d2f8d 100644 index 52d80086deff664fcfd8952b7cabbfa1f48ad131..a86b5272c0ac4dd64f796f7fd025c7a34a5d2f8d 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
@ -33,7 +20,7 @@ index 52d80086deff664fcfd8952b7cabbfa1f48ad131..a86b5272c0ac4dd64f796f7fd025c7a3
private boolean tickingBlockEntities; private boolean tickingBlockEntities;
public final Thread thread; public final Thread thread;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 5133febf4b3a83b2870fee2f9e45b1d12894df54..e11a1a21bff1fc5e730d6c63c5b0c623b3b2e037 100644 index 5133febf4b3a83b2870fee2f9e45b1d12894df54..10b046ed843acac205608fa2fa3ffd4e4a277b5c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -270,6 +270,57 @@ public class CraftWorld implements World { @@ -270,6 +270,57 @@ public class CraftWorld implements World {
@ -87,7 +74,7 @@ index 5133febf4b3a83b2870fee2f9e45b1d12894df54..e11a1a21bff1fc5e730d6c63c5b0c623
+ +
+ @Override + @Override
+ public int getPlayerCount() { + public int getPlayerCount() {
+ return world.getPlayerListSize(); + return world.players().size();
+ } + }
+ // Paper end + // Paper end
+ +

View File

@ -9,7 +9,7 @@ In Offline Mode, will return an Offline UUID
This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 10addb128a357e7719854bf4f9d75f5def32b27d..20915e40fbcf28faed603d449a99bf2157fcf972 100644 index cb09b6170a74984628f2c3dbacad2ddc9fe56faf..df94ac3f5319cd990f5592d57d2e319c84f51524 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1517,6 +1517,25 @@ public final class CraftServer implements Server { @@ -1517,6 +1517,25 @@ public final class CraftServer implements Server {

View File

@ -28,19 +28,19 @@ respond to the request.
[2]: https://netty.io/wiki/user-guide-for-4.x.html#wiki-h4-13 [2]: https://netty.io/wiki/user-guide-for-4.x.html#wiki-h4-13
diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
index e2867a3de87a778a897b4963212fa4aab566a643..1d11802876c1a94ecf991cd8249bd6a911c0ac20 100644 index a2b0237a27379d05e8ca15cb033ee3fd2a5bb29b..6a759cfd0c2df4daaf126d12d20ac8d701e41f9d 100644
--- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java --- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
+++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java +++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
@@ -15,6 +15,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -16,6 +16,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
public static final int FAKE_PROTOCOL_VERSION = 127;
private final ServerConnectionListener serverConnectionListener; private final ServerConnectionListener serverConnectionListener;
+ private ByteBuf buf; // Paper + private ByteBuf buf; // Paper
public LegacyQueryHandler(ServerConnectionListener networkIo) { public LegacyQueryHandler(ServerConnectionListener networkIo) {
this.serverConnectionListener = networkIo; this.serverConnectionListener = networkIo;
@@ -23,6 +24,16 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -24,6 +25,16 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) throws Exception { public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) {
ByteBuf bytebuf = (ByteBuf) object; ByteBuf bytebuf = (ByteBuf) object;
+ // Paper start - Make legacy ping handler more reliable + // Paper start - Make legacy ping handler more reliable
@ -56,7 +56,7 @@ index e2867a3de87a778a897b4963212fa4aab566a643..1d11802876c1a94ecf991cd8249bd6a9
bytebuf.markReaderIndex(); bytebuf.markReaderIndex();
boolean flag = true; boolean flag = true;
@@ -53,6 +64,10 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -54,6 +65,10 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
this.sendFlushAndClose(channelhandlercontext, this.createReply(s)); this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break; break;
default: default:
@ -67,20 +67,7 @@ index e2867a3de87a778a897b4963212fa4aab566a643..1d11802876c1a94ecf991cd8249bd6a9
boolean flag1 = bytebuf.readUnsignedByte() == 1; boolean flag1 = bytebuf.readUnsignedByte() == 1;
flag1 &= bytebuf.readUnsignedByte() == 250; flag1 &= bytebuf.readUnsignedByte() == 250;
@@ -67,15 +82,16 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -77,6 +92,7 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
return;
}
- LegacyQueryHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
- ByteBuf bytebuf1 = this.createReply(s1);
+ LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
+ ByteBuf bytebuf1 = this.a(s1);
try {
- this.sendFlushAndClose(channelhandlercontext, bytebuf1);
+ this.a(channelhandlercontext, bytebuf1);
} finally { } finally {
bytebuf1.release(); bytebuf1.release();
} }
@ -88,7 +75,7 @@ index e2867a3de87a778a897b4963212fa4aab566a643..1d11802876c1a94ecf991cd8249bd6a9
} }
bytebuf.release(); bytebuf.release();
@@ -93,6 +109,90 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -94,6 +110,90 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
} }

View File

@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..74c012fd40491f1d870fbc1aa8c318a2
+ +
+} +}
diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
index 1d11802876c1a94ecf991cd8249bd6a911c0ac20..dfe2cd46f2432dca2028b7436c4108e3f190787f 100644 index 6a759cfd0c2df4daaf126d12d20ac8d701e41f9d..3962e82d4e4c5f792a37e825891e6960e737452d 100644
--- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java --- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
+++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java +++ b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java
@@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
@ -95,7 +95,7 @@ index 1d11802876c1a94ecf991cd8249bd6a911c0ac20..dfe2cd46f2432dca2028b7436c4108e3
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
@@ -46,12 +48,19 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -47,12 +49,19 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
MinecraftServer minecraftserver = this.serverConnectionListener.getServer(); MinecraftServer minecraftserver = this.serverConnectionListener.getServer();
int i = bytebuf.readableBytes(); int i = bytebuf.readableBytes();
String s; String s;
@ -117,7 +117,7 @@ index 1d11802876c1a94ecf991cd8249bd6a911c0ac20..dfe2cd46f2432dca2028b7436c4108e3
this.sendFlushAndClose(channelhandlercontext, this.createReply(s)); this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break; break;
case 1: case 1:
@@ -60,7 +69,14 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -61,7 +70,14 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
} }
LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
@ -133,7 +133,7 @@ index 1d11802876c1a94ecf991cd8249bd6a911c0ac20..dfe2cd46f2432dca2028b7436c4108e3
this.sendFlushAndClose(channelhandlercontext, this.createReply(s)); this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break; break;
default: default:
@@ -170,8 +186,16 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter { @@ -171,8 +187,16 @@ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress()); LOGGER.debug("Ping: (1.6) from {}", ctx.channel().remoteAddress());

View File

@ -9,10 +9,10 @@ e.g. servers which allow and support the usage of mod packs.
provide an optional flag to disable this check, at your own risk. provide an optional flag to disable this check, at your own risk.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 9d853733ff9054cc48925e22c8bb3c8d9b898808..46338fe5693003698de9c7b37a860c3481e06233 100644 index 8bf0c74ee32e8cb7c0f48bc964552811ad6ee468..8df1894df3583840412ccc7ccdc4b23db6dd6265 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -143,6 +143,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -148,6 +148,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper start // Paper start
private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
private String resourcePackHash; private String resourcePackHash;
@ -20,12 +20,12 @@ index 9d853733ff9054cc48925e22c8bb3c8d9b898808..46338fe5693003698de9c7b37a860c34
// Paper end // Paper end
public CraftPlayer(CraftServer server, ServerPlayer entity) { public CraftPlayer(CraftServer server, ServerPlayer entity) {
@@ -1576,7 +1577,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1589,7 +1590,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public void addChannel(String channel) { public void addChannel(String channel) {
- Preconditions.checkState(channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel); - Preconditions.checkState(this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel);
+ Preconditions.checkState(DISABLE_CHANNEL_LIMIT || channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel); // Paper - flag to disable channel limit + Preconditions.checkState(DISABLE_CHANNEL_LIMIT || this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel); // Paper - flag to disable channel limit
channel = StandardMessenger.validateAndCorrectChannel(channel); channel = StandardMessenger.validateAndCorrectChannel(channel);
if (channels.add(channel)) { if (this.channels.add(channel)) {
server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel));

View File

@ -5,18 +5,10 @@ Subject: [PATCH] Add method to open already placed sign
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index c62d01719f21762aa10294815ab88e450e4dce3f..4aec1c2b26d48cb5bea3dfb9e183526763bdb98f 100644 index 6c404878e58f68c9ac86a1771c23e528f3817e32..7f7322b5174a7580675b0607b0f282f7bf75a3e2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -28,6 +28,7 @@ import net.minecraft.world.level.block.Blocks; @@ -604,6 +604,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.EnchantmentTableBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -604,6 +605,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
} }
} }
@ -25,12 +17,12 @@ index c62d01719f21762aa10294815ab88e450e4dce3f..4aec1c2b26d48cb5bea3dfb9e1835267
+ public void openSign(org.bukkit.block.Sign sign) { + public void openSign(org.bukkit.block.Sign sign) {
+ org.apache.commons.lang.Validate.isTrue(sign.getWorld().equals(this.getWorld()), "Sign must be in the same world as player is in"); + org.apache.commons.lang.Validate.isTrue(sign.getWorld().equals(this.getWorld()), "Sign must be in the same world as player is in");
+ org.bukkit.craftbukkit.block.CraftSign craftSign = (org.bukkit.craftbukkit.block.CraftSign) sign; + org.bukkit.craftbukkit.block.CraftSign craftSign = (org.bukkit.craftbukkit.block.CraftSign) sign;
+ SignBlockEntity teSign = craftSign.getTileEntity(); + net.minecraft.world.level.block.entity.SignBlockEntity teSign = craftSign.getTileEntity();
+ // Make sign editable temporarily, will be set back to false in PlayerConnection later + // Make sign editable temporarily, will be set back to false in PlayerConnection later
+ teSign.isEditable = true; + teSign.isEditable = true;
+ getHandle().openTextEdit(teSign); + this.getHandle().openTextEdit(teSign);
+ } + }
+ // Paper end + // Paper end
@Override @Override
public boolean dropItem(boolean dropAll) { public boolean dropItem(boolean dropAll) {
return getHandle().drop(dropAll); return this.getHandle().drop(dropAll);

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Configurable sprint interruption on attack
If the sprint interruption is disabled players continue sprinting when they attack entities. If the sprint interruption is disabled players continue sprinting when they attack entities.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 48f0385c7203c7955de5a015f3dc42be2ab7b681..cebf1a623a9bec72d60fdd23dda01868ef6431d4 100644 index da4a110809eee691c1d5b072de335d75e1516eae..9225372cb9ef51a8cfbd4cee543c250aa2ac9c49 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -358,4 +358,9 @@ public class PaperWorldConfig { @@ -352,4 +352,9 @@ public class PaperWorldConfig {
private void squidMaxSpawnHeight() { private void squidMaxSpawnHeight() {
squidMaxSpawnHeight = getDouble("squid-spawn-height.maximum", 0.0D); squidMaxSpawnHeight = getDouble("squid-spawn-height.maximum", 0.0D);
} }
@ -20,10 +20,10 @@ index 48f0385c7203c7955de5a015f3dc42be2ab7b681..cebf1a623a9bec72d60fdd23dda01868
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 c4aa824d03de952fe6b306e539baa47af979add1..552920f59aae9de2cad3edcdc8c48a91dff49093 100644 index 3c0aca2b90521da83cf494d9fff953a17a57701d..a3f719d9dc63af9decc54a789f04595bb2d55710 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1180,7 +1180,11 @@ public abstract class Player extends LivingEntity { @@ -1240,7 +1240,11 @@ public abstract class Player extends LivingEntity {
} }
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));

View File

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: 0x22 <0x22@futureclient.net>
Date: Thu, 26 Apr 2018 04:41:11 -0400
Subject: [PATCH] Fix exploit that allowed colored signs to be created
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 205e4ef25f49edc11a408c302d9ba68a59c68a5a..35a00a622ff0c3582e08dbbefb1d34a84e590a81 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2787,9 +2787,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
for (int i = 0; i < list.size(); ++i) {
if (this.player.isTextFilteringEnabled()) {
- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getFiltered()));
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered())));
} else {
- lines.add(net.kyori.adventure.text.Component.text(list.get(i).getRaw()));
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw())));
}
}
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.cserver.getPlayer(this.player), lines);

View File

@ -8,44 +8,36 @@ Fires an event anytime an enderman intends to teleport away from the player
You may cancel this, enabling ranged attacks to damage the enderman for example. You may cancel this, enabling ranged attacks to damage the enderman for example.
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 1c2998c89fd660d6b26b7ff48cddd1862b9b1828..1b9c77666204765a3ed5648b0f8eaa820f578e58 100644 index a18765fe0be5a83ee2da3638aa5107e9345f19b6..29e53aebd1dc22d5dd2753cc7acbea425cb0054e 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -2,6 +2,7 @@ package net.minecraft.world.entity.monster; @@ -109,6 +109,12 @@ public class EnderMan extends Monster implements NeutralMob {
this.setGoalTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
import java.util.EnumSet;
import java.util.Optional;
+import com.destroystokyo.paper.event.entity.EndermanEscapeEvent; // Paper
import java.util.Random;
import java.util.UUID;
import java.util.function.Predicate;
@@ -109,6 +110,12 @@ public class EnderMan extends Monster implements NeutralMob {
setGoalTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
} }
+ // Paper start + // Paper start
+ private boolean tryEscape(EndermanEscapeEvent.Reason reason) { + private boolean tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason reason) {
+ return new EndermanEscapeEvent((org.bukkit.craftbukkit.entity.CraftEnderman) this.getBukkitEntity(), reason).callEvent(); + return new com.destroystokyo.paper.event.entity.EndermanEscapeEvent((org.bukkit.craftbukkit.entity.CraftEnderman) this.getBukkitEntity(), reason).callEvent();
+ } + }
+ // Paper end + // Paper end
+ +
@Override @Override
public boolean setGoalTarget(LivingEntity entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { public boolean setGoalTarget(LivingEntity entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
if (!super.setGoalTarget(entityliving, reason, fireEvent)) { if (!super.setGoalTarget(entityliving, reason, fireEvent)) {
@@ -262,7 +269,7 @@ public class EnderMan extends Monster implements NeutralMob { @@ -262,7 +268,7 @@ public class EnderMan extends Monster implements NeutralMob {
if (this.level.isDay() && this.tickCount >= this.targetChangeTime + 600) { if (this.level.isDay() && this.tickCount >= this.targetChangeTime + 600) {
float f = this.getBrightness(); float f = this.getBrightness();
- if (f > 0.5F && this.level.canSeeSky(this.blockPosition()) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { - if (f > 0.5F && this.level.canSeeSky(this.blockPosition()) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
+ if (f > 0.5F && this.level.canSeeSky(this.blockPosition()) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.tryEscape(EndermanEscapeEvent.Reason.RUNAWAY)) { // Paper + if (f > 0.5F && this.level.canSeeSky(this.blockPosition()) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.RUNAWAY)) { // Paper
this.setTarget((LivingEntity) null); this.setTarget((LivingEntity) null);
this.teleport(); this.teleport();
} }
@@ -360,17 +367,19 @@ public class EnderMan extends Monster implements NeutralMob { @@ -360,17 +366,19 @@ public class EnderMan extends Monster implements NeutralMob {
if (this.isInvulnerableTo(source)) { if (this.isInvulnerableTo(source)) {
return false; return false;
} else if (source instanceof IndirectEntityDamageSource) { } else if (source instanceof IndirectEntityDamageSource) {
+ if (this.tryEscape(EndermanEscapeEvent.Reason.INDIRECT)) { // Paper start + if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper start
for (int i = 0; i < 64; ++i) { for (int i = 0; i < 64; ++i) {
if (this.teleport()) { if (this.teleport()) {
return true; return true;
@ -58,25 +50,25 @@ index 1c2998c89fd660d6b26b7ff48cddd1862b9b1828..1b9c77666204765a3ed5648b0f8eaa82
boolean flag = super.hurt(source, amount); boolean flag = super.hurt(source, amount);
- if (!this.level.isClientSide() && !(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0) { - if (!this.level.isClientSide() && !(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0) {
+ if (!this.level.isClientSide() && !(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0 && this.tryEscape(source == DamageSource.DROWN ? EndermanEscapeEvent.Reason.DROWN : EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - use to be critical hits as else, but mojang removed critical hits in 1.16.2 due to MC-185684 + if (!this.level.isClientSide() && !(source.getEntity() instanceof LivingEntity) && this.random.nextInt(10) != 0 && this.tryEscape(source == DamageSource.DROWN ? com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.DROWN : com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - use to be critical hits as else, but mojang removed critical hits in 1.16.2 due to MC-185684
this.teleport(); this.teleport();
} }
@@ -515,7 +524,7 @@ public class EnderMan extends Monster implements NeutralMob { @@ -516,7 +524,7 @@ public class EnderMan extends Monster implements NeutralMob {
static class EndermanLookForPlayerGoal extends NearestAttackableTargetGoal<Player> { private static class EndermanLookForPlayerGoal extends NearestAttackableTargetGoal<Player> {
- private final EnderMan enderman; - private final EnderMan enderman;
+ private final EnderMan enderman; public final EnderMan getEnderman() { return this.enderman; } // Paper - OBFHELPER + private final EnderMan enderman; public final EnderMan getEnderman() { return this.enderman; } // Paper - OBFHELPER
private Player pendingTarget; private Player pendingTarget;
private int aggroTime; private int aggroTime;
private int teleportTime; private int teleportTime;
@@ -578,7 +587,7 @@ public class EnderMan extends Monster implements NeutralMob { @@ -579,7 +587,7 @@ public class EnderMan extends Monster implements NeutralMob {
} else { } else {
if (this.target != null && !this.enderman.isPassenger()) { if (this.target != null && !this.enderman.isPassenger()) {
if (this.enderman.isLookingAtMe((Player) this.target)) { if (this.enderman.isLookingAtMe((Player) this.target)) {
- if (this.target.distanceToSqr((Entity) this.enderman) < 16.0D) { - if (this.target.distanceToSqr((Entity) this.enderman) < 16.0D) {
+ if (this.target.distanceToSqr((Entity) this.enderman) < 16.0D && this.getEnderman().tryEscape(EndermanEscapeEvent.Reason.STARE)) { // Paper + if (this.target.distanceToSqr((Entity) this.enderman) < 16.0D && this.getEnderman().tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.STARE)) { // Paper
this.enderman.teleport(); this.enderman.teleport();
} }

View File

@ -6,26 +6,27 @@ Subject: [PATCH] Enderman.teleportRandomly()
Ability to trigger the vanilla "teleport randomly" mechanic of an enderman. Ability to trigger the vanilla "teleport randomly" mechanic of an enderman.
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 1b9c77666204765a3ed5648b0f8eaa820f578e58..1981c08af85b16d45531ffae4fe790bb31edec04 100644 index 29e53aebd1dc22d5dd2753cc7acbea425cb0054e..dedab212105f55ebce31f2309e34d8c3136c193f 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -278,6 +278,7 @@ public class EnderMan extends Monster implements NeutralMob { @@ -277,7 +277,7 @@ public class EnderMan extends Monster implements NeutralMob {
super.customServerAiStep(); super.customServerAiStep();
} }
+ public final boolean teleportRandomly() { return this.teleport(); } // Paper - OBFHELPER - protected boolean teleport() {
protected boolean teleport() { + public boolean teleport() { // Paper - protected->public
if (!this.level.isClientSide() && this.isAlive()) { if (!this.level.isClientSide() && this.isAlive()) {
double d0 = this.getX() + (this.random.nextDouble() - 0.5D) * 64.0D; double d0 = this.getX() + (this.random.nextDouble() - 0.5D) * 64.0D;
double d1 = this.getY() + (double) (this.random.nextInt(64) - 32);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
index d17ed71e800ebcd12b69745f239fa7dbc8a0c808..1edb45490b35b6517201acc8551da8d3c5a489de 100644 index b72d7ade10075a13a617a370e2b8021326c9478d..ae669a970aa1f17ed786640de8a481364543c58e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
@@ -16,6 +16,7 @@ public class CraftEnderman extends CraftMonster implements Enderman { @@ -16,6 +16,7 @@ public class CraftEnderman extends CraftMonster implements Enderman {
super(server, entity); super(server, entity);
} }
+ @Override public boolean teleportRandomly() { return getHandle().teleportRandomly(); } // Paper + @Override public boolean teleportRandomly() { return getHandle().teleport(); } // Paper
@Override @Override
public MaterialData getCarriedMaterial() { public MaterialData getCarriedMaterial() {
BlockState blockData = getHandle().getCarriedBlock(); BlockState blockData = this.getHandle().getCarriedBlock();

View File

@ -12,10 +12,10 @@ This disables that by not saving the thrower when the chunk is unloaded.
This is mainly useful for survival servers that do not allow freeform teleporting. This is mainly useful for survival servers that do not allow freeform teleporting.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index cebf1a623a9bec72d60fdd23dda01868ef6431d4..e8e1e7dafaf1c105b2f58cf3e118e3d665dc50ec 100644 index 9225372cb9ef51a8cfbd4cee543c250aa2ac9c49..a0a846a2e60bdc17537bd697137f65321c1a61d8 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -363,4 +363,10 @@ public class PaperWorldConfig { @@ -357,4 +357,10 @@ public class PaperWorldConfig {
private void disableSprintInterruptionOnAttack() { private void disableSprintInterruptionOnAttack() {
disableSprintInterruptionOnAttack = getBoolean("game-mechanics.disable-sprint-interruption-on-attack", false); disableSprintInterruptionOnAttack = getBoolean("game-mechanics.disable-sprint-interruption-on-attack", false);
} }
@ -27,14 +27,14 @@ index cebf1a623a9bec72d60fdd23dda01868ef6431d4..e8e1e7dafaf1c105b2f58cf3e118e3d6
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
index 14ed4f212a9c9c3128c4ddbef7b2e243c925b509..16b554675a276471851846d4f2bea06fdcc166d9 100644 index c72ec22beff6aa1f7932fa44dc7d591ceeec1158..c25cb17ef1a7c56e10ce3ccb5665c9dce3e6efa6 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -62,6 +62,7 @@ public abstract class Projectile extends Entity { @@ -88,6 +88,7 @@ public abstract class Projectile extends Entity {
protected void readAdditionalSaveData(CompoundTag tag) { protected void readAdditionalSaveData(CompoundTag nbt) {
if (tag.hasUUID("Owner")) { if (nbt.hasUUID("Owner")) {
this.ownerUUID = tag.getUUID("Owner"); this.ownerUUID = nbt.getUUID("Owner");
+ if (this instanceof ThrownEnderpearl && this.level != null && this.level.paperConfig.disableEnderpearlExploit) { this.ownerUUID = null; } // Paper - Don't store shooter name for pearls to block enderpearl travel exploit + if (this instanceof ThrownEnderpearl && this.level != null && this.level.paperConfig.disableEnderpearlExploit) { this.ownerUUID = null; } // Paper - Don't store shooter name for pearls to block enderpearl travel exploit
} }
this.leftOwner = tag.getBoolean("LeftOwner"); this.leftOwner = nbt.getBoolean("LeftOwner");

View File

@ -10,19 +10,10 @@ Adds an option to control the force mode of the particle.
This adds a new Builder API which is much friendlier to use. This adds a new Builder API which is much friendlier to use.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 20650bfd10abfa010e71cfeede06c461d50d19a3..5110f2c70d96284e8e7592b3d89266b867b9a466 100644 index 8323ddb363f49d266dd95f11241a30a9a27250aa..cf074ef0cb01bc2cbd8c529e7233ceb9443f764d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -164,7 +164,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl @@ -1287,12 +1287,17 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
public final Int2ObjectMap<Entity> entitiesById = new Int2ObjectLinkedOpenHashMap();
private final Map<UUID, Entity> entitiesByUuid = Maps.newHashMap();
private final Queue<Entity> toAddAfterTick = Queues.newArrayDeque();
- private final List<ServerPlayer> players = Lists.newArrayList();
+ public final List<ServerPlayer> players = Lists.newArrayList(); // Paper - private -> public
public final ServerChunkCache chunkSource; // Paper - public
boolean tickingEntities;
private final MinecraftServer server;
@@ -1472,12 +1472,17 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
} }
public <T extends ParticleOptions> int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { public <T extends ParticleOptions> int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
@ -43,10 +34,10 @@ index 20650bfd10abfa010e71cfeede06c461d50d19a3..5110f2c70d96284e8e7592b3d89266b8
if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 88658d4deacc29128c537e2e02fdc8f684090a2c..beb7219312be5143a50b0841c25efea5dbcc1267 100644 index bc80e0062ef679e7cb147bd1a6da52bf95da52b8..ab59b0e9dc827e7ebe0c4dea633680908dcb5874 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2334,11 +2334,17 @@ public class CraftWorld implements World { @@ -2355,11 +2355,17 @@ public class CraftWorld implements World {
@Override @Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
@ -58,9 +49,9 @@ index 88658d4deacc29128c537e2e02fdc8f684090a2c..beb7219312be5143a50b0841c25efea5
if (data != null && !particle.getDataType().isInstance(data)) { if (data != null && !particle.getDataType().isInstance(data)) {
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass()); throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
} }
getHandle().sendParticles( this.getHandle().sendParticles(
- null, // Sender - null, // Sender
+ receivers == null ? getHandle().players : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API Expansion + receivers == null ? getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API Expansion
+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion + sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion
CraftParticle.toNMS(particle, data), // Particle CraftParticle.toNMS(particle, data), // Particle
x, y, z, // Position x, y, z, // Position

View File

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 10 Mar 2018 16:33:15 -0500
Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks
1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded.
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
index 54eb7ba0265bb155dd1c753661242fa9d299ff80..5b5d606a794c885267b6f5e2bbfe9b0a318ad767 100644
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
@@ -38,7 +38,8 @@ public class FrostedIceBlock extends IceBlock {
for(Direction direction : Direction.values()) {
mutableBlockPos.setWithOffset(pos, direction);
- BlockState blockState = world.getBlockState(mutableBlockPos);
+ BlockState blockState = world.getTypeIfLoaded(mutableBlockPos); // Paper
+ if (blockState == null) { continue; } // Paper
if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) {
world.getBlockTicks().scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay
}
@@ -75,7 +76,10 @@ public class FrostedIceBlock extends IceBlock {
for(Direction direction : Direction.values()) {
mutableBlockPos.setWithOffset(pos, direction);
- if (world.getBlockState(mutableBlockPos).is(this)) {
+ // Paper start
+ BlockState blockState = world.getTypeIfLoaded(mutableBlockPos);
+ if (blockState != null && blockState.is(this)) {
+ // Paper end
++i;
if (i >= maxNeighbors) {
return false;

View File

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 1 May 2018 20:18:54 -0400
Subject: [PATCH] EndermanAttackPlayerEvent
Allow control over whether or not an enderman aggros a player.
This allows you to override/extend the pumpkin/stare logic.
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index dedab212105f55ebce31f2309e34d8c3136c193f..abd1130529dd74780054e26bac89cf757ba9cdc1 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -220,7 +220,15 @@ public class EnderMan extends Monster implements NeutralMob {
this.readPersistentAngerSaveData(this.level, nbt);
}
- boolean isLookingAtMe(Player player) {
+ // Paper start - EndermanAttackPlayerEvent
+ private boolean isLookingAtMe(Player player) {
+ boolean shouldAttack = isLookingAtMe_check(player);
+ com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
+ event.setCancelled(!shouldAttack);
+ return event.callEvent();
+ }
+ private boolean isLookingAtMe_check(Player player) {
+ // Paper end
ItemStack itemstack = (ItemStack) player.getInventory().armor.get(3);
if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) {

View File

@ -6,13 +6,13 @@ Subject: [PATCH] WitchConsumePotionEvent
Fires when a witch consumes the potion in their hand Fires when a witch consumes the potion in their hand
diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java
index 9b0269bdd25123f5c0662187de49a869ead3ee81..dd5976d81ff57e8691ba60f425af37572edd26e7 100644 index 0c04665c6e2f5624e21e269d706fea842d54cefd..ecb3843ff3b4f0034f6aaa16cfc09cbd046d9008 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Witch.java --- a/src/main/java/net/minecraft/world/entity/monster/Witch.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java +++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java
@@ -124,7 +124,11 @@ public class Witch extends Raider implements RangedAttackMob { @@ -124,7 +124,11 @@ public class Witch extends Raider implements RangedAttackMob {
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
if (itemstack.getItem() == Items.POTION) { if (itemstack.is(Items.POTION)) {
- List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack); - List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack);
+ // Paper start + // Paper start
+ com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); + com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));

View File

@ -6,10 +6,10 @@ Subject: [PATCH] WitchThrowPotionEvent
Fired when a witch throws a potion at a player Fired when a witch throws a potion at a player
diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java
index dd5976d81ff57e8691ba60f425af37572edd26e7..7cefabfb0d8a264cae24f23c06f1c5f552ff0158 100644 index ecb3843ff3b4f0034f6aaa16cfc09cbd046d9008..e2762c6c37975eb2da59d408998a5c0368c146d1 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Witch.java --- a/src/main/java/net/minecraft/world/entity/monster/Witch.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java +++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java
@@ -224,9 +224,16 @@ public class Witch extends Raider implements RangedAttackMob { @@ -236,9 +236,16 @@ public class Witch extends Raider implements RangedAttackMob {
potionregistry = Potions.WEAKNESS; potionregistry = Potions.WEAKNESS;
} }
@ -25,6 +25,6 @@ index dd5976d81ff57e8691ba60f425af37572edd26e7..7cefabfb0d8a264cae24f23c06f1c5f5
- entitypotion.setItem(PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry)); - entitypotion.setItem(PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry));
+ entitypotion.setItem(potion); + entitypotion.setItem(potion);
+ // Paper end + // Paper end
entitypotion.xRot -= -20.0F; entitypotion.setXRot(entitypotion.getXRot() - -20.0F);
entitypotion.shoot(d0, d1 + (double) (f1 * 0.2F), d2, 0.75F, 8.0F); entitypotion.shoot(d0, d1 + d3 * 0.2D, d2, 0.75F, 8.0F);
if (!this.isSilent()) { if (!this.isSilent()) {

View File

@ -8,17 +8,17 @@ This API has more capabilities than .dropItem with the Consumer function
Item can be set inside of the Consumer pre spawn function. Item can be set inside of the Consumer pre spawn function.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index beb7219312be5143a50b0841c25efea5dbcc1267..2dc9daaeea600fff1f2efddf74b6849fd745a28c 100644 index ab59b0e9dc827e7ebe0c4dea633680908dcb5874..058346b89c07d44a5425a61abedcfc440cb9ee21 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1497,6 +1497,10 @@ public class CraftWorld implements World { @@ -1505,6 +1505,10 @@ public class CraftWorld implements World {
if (Boat.class.isAssignableFrom(clazz)) { if (Boat.class.isAssignableFrom(clazz)) {
entity = new net.minecraft.world.entity.vehicle.Boat(world, x, y, z); entity = new net.minecraft.world.entity.vehicle.Boat(this.world, x, y, z);
entity.moveTo(x, y, z, yaw, pitch); entity.moveTo(x, y, z, yaw, pitch);
+ // Paper start + // Paper start
+ } else if (org.bukkit.entity.Item.class.isAssignableFrom(clazz)) { + } else if (org.bukkit.entity.Item.class.isAssignableFrom(clazz)) {
+ entity = new ItemEntity(world, x, y, z, new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Item.byBlock(net.minecraft.world.level.block.Blocks.DIRT))); + entity = new ItemEntity(world, x, y, z, new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Item.byBlock(net.minecraft.world.level.block.Blocks.DIRT)));
+ // Paper end + // Paper end
} else if (FallingBlock.class.isAssignableFrom(clazz)) { } else if (FallingBlock.class.isAssignableFrom(clazz)) {
entity = new FallingBlockEntity(world, x, y, z, world.getBlockState(new BlockPos(x, y, z))); entity = new FallingBlockEntity(this.world, x, y, z, this.world.getBlockState(new BlockPos(x, y, z)));
} else if (Projectile.class.isAssignableFrom(clazz)) { } else if (Projectile.class.isAssignableFrom(clazz)) {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] WitchReadyPotionEvent
diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java
index 7cefabfb0d8a264cae24f23c06f1c5f552ff0158..a37ee32b46aa87be6e3eeca2892b4e7294fd1aef 100644 index e2762c6c37975eb2da59d408998a5c0368c146d1..5e2e8cb5eba4ba36065f07abed954b2aad022321 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Witch.java --- a/src/main/java/net/minecraft/world/entity/monster/Witch.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java +++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java
@@ -157,7 +157,11 @@ public class Witch extends Raider implements RangedAttackMob { @@ -157,7 +157,11 @@ public class Witch extends Raider implements RangedAttackMob {

View File

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 23:00:29 -0400
Subject: [PATCH] ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 51c1f62af5c25fe620f1d8a9cb03473e849db68d..3fbfe4f77c4b82d96ed022498b2d9175d548e247 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -173,6 +173,13 @@ public final class CraftItemStack extends ItemStack {
return (this.handle == null) ? Material.AIR.getMaxStackSize() : this.handle.getItem().getMaxStackSize();
}
+ // Paper start
+ @Override
+ public int getMaxItemUseDuration() {
+ return handle == null ? 0 : handle.getUseDuration();
+ }
+ // Paper end
+
@Override
public void addUnsafeEnchantment(Enchantment ench, int level) {
Validate.notNull(ench, "Cannot add null enchantment");

View File

@ -5,28 +5,28 @@ Subject: [PATCH] Implement EntityTeleportEndGatewayEvent
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
index 2c974f9801d209907733bed8e6c4c9ef46e2b610..b70e0633435a272ae1e9fbd12d7f18862de0b951 100644 index 2bf65c8da827c6bdbfb74a9d8ee5754584c40c53..f9cd4c28db815205e548ac59515cd80989741bab 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
@@ -191,9 +191,20 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity implements @@ -225,9 +225,20 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
} }
// CraftBukkit end // CraftBukkit end
+ // Paper start - EntityTeleportEndGatewayEvent - replicated from above + // Paper start - EntityTeleportEndGatewayEvent - replicated from above
+ org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity = entity.getBukkitEntity(); + org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity = entity.getBukkitEntity();
+ org.bukkit.Location location = new Location(level.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D); + org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D);
+ location.setPitch(bukkitEntity.getLocation().getPitch()); + location.setPitch(bukkitEntity.getLocation().getPitch());
+ location.setYaw(bukkitEntity.getLocation().getYaw()); + location.setYaw(bukkitEntity.getLocation().getYaw());
+ +
+ com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(MCUtil.toLocation(level, this.getBlockPos()).getBlock())); + com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(MCUtil.toLocation(world, blockEntity.getBlockPos()).getBlock()));
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ return; + return;
+ } + }
+ // Paper end + // Paper end
entity1.setPortalCooldown(); entity1.setPortalCooldown();
- entity1.teleportToWithTicket((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); - entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D);
+ entity1.teleportToWithTicket(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); // Paper + entity1.teleportToWithTicket(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); // Paper
} }
this.triggerCooldown(); TheEndGatewayBlockEntity.triggerCooldown(world, pos, state, blockEntity);

View File

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 Jun 2018 01:18:49 -0400
Subject: [PATCH] Unset Ignited flag on cancel of Explosion Event
Otherwise the creeper infinite explodes
diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
index ddc48d37f962b6743f3f356745c9ebe6a06f79f1..3bbf6c9bfbb79fd4242cf66d7ace1d8f87404636 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -272,6 +272,7 @@ public class Creeper extends Monster implements PowerableMob {
this.spawnLingeringCloud();
} else {
this.swell = 0;
+ this.entityData.set(DATA_IS_IGNITED, Boolean.valueOf(false)); // Paper
}
// CraftBukkit end
}

View File

@ -21,10 +21,10 @@ check is essentially the same as this.getHandle() == other.getHandle()
However, replaced it too to make it clearer of intent. However, replaced it too to make it clearer of intent.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index ecb5f5ca547930f91602d539e541964cd9f10287..e1bbaf620f3ed2a6cb9ce8007a78c4cee47b653e 100644 index 1fd891b53c54153c28d636b2679b4a083510ba3c..0bc816407157264bf3e736da678535d08b4d85f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -745,14 +745,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { @@ -782,14 +782,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return false; return false;
} }
final CraftEntity other = (CraftEntity) obj; final CraftEntity other = (CraftEntity) obj;

View File

@ -53,47 +53,22 @@ index 05a5abb951abe37f30a719cb75376d2d43c0d252..77a03abd59db4a43f6f2d59d4c7ef176
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java diff --git a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java
index ceb5e5405ed20c8de954847bbb269109107a43fc..d99bc0b8a1e9c4749b176a823b879ced9efdd7d6 100644 index 710a66e9aafe8bd622f9f37789c281aba98d030e..558f43580d976d7bde32779e47e24c9ad388892d 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java --- a/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java
@@ -8,7 +8,6 @@ import java.util.List; @@ -113,9 +113,35 @@ public abstract class LootPoolSingletonContainer extends LootPoolEntryContainer
import java.util.function.BiFunction; protected abstract class EntryBase implements LootPoolEntry {
import java.util.function.Consumer;
import net.minecraft.util.GsonHelper;
-import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.ValidationContext;
@@ -20,8 +19,8 @@ import org.apache.commons.lang3.ArrayUtils;
public abstract class LootPoolSingletonContainer extends LootPoolEntryContainer {
- protected final int weight;
- protected final int quality;
+ protected final int weight; public int getWeight() { return weight; } // Paper - OBFHELPER
+ protected final int quality; public int getQuality() { return quality; } // Paper - OBFHELPER
protected final LootItemFunction[] functions;
private final BiFunction<ItemStack, LootContext, ItemStack> compositeFunction;
private final LootPoolEntry entry = new LootPoolSingletonContainer.EntryBase() {
@@ -152,11 +151,38 @@ public abstract class LootPoolSingletonContainer extends LootPoolEntryContainer
public abstract class EntryBase implements LootPoolEntry {
- protected EntryBase() {}
+ protected EntryBase() {
+ }
@Override @Override
public int getWeight(float luck) { public int getWeight(float luck) {
- return Math.max(Mth.floor((float) LootPoolSingletonContainer.this.weight + (float) LootPoolSingletonContainer.this.quality * luck), 0); - return Math.max(Mth.floor((float)LootPoolSingletonContainer.this.weight + (float)LootPoolSingletonContainer.this.quality * luck), 0);
+ // Paper start - Offer an alternative loot formula to refactor how luck bonus applies + // Paper start - Offer an alternative loot formula to refactor how luck bonus applies
+ // SEE: https://luckformula.emc.gs for details and data + // SEE: https://luckformula.emc.gs for details and data
+ if (lastLuck != null && lastLuck == luck) { + if (LootPoolSingletonContainer.this.lastLuck != null && LootPoolSingletonContainer.this.lastLuck == luck) {
+ return lastWeight; + return lastWeight;
+ } + }
+ // This is vanilla + // This is vanilla
+ float qualityModifer = (float) getQuality() * luck; + float qualityModifer = (float) LootPoolSingletonContainer.this.quality * luck;
+ double baseWeight = (getWeight() + qualityModifer); + double baseWeight = (LootPoolSingletonContainer.this.weight + qualityModifer);
+ if (com.destroystokyo.paper.PaperConfig.useAlternativeLuckFormula) { + if (com.destroystokyo.paper.PaperConfig.useAlternativeLuckFormula) {
+ // Random boost to avoid losing precision in the final int cast on return + // Random boost to avoid losing precision in the final int cast on return
+ final int weightBoost = 100; + final int weightBoost = 100;
@ -107,12 +82,14 @@ index ceb5e5405ed20c8de954847bbb269109107a43fc..d99bc0b8a1e9c4749b176a823b879ced
+ // =B2 - (C2 *($B$7/100)) + // =B2 - (C2 *($B$7/100))
+ baseWeight = Math.ceil(baseWeight - (impacted * luckModifier)); + baseWeight = Math.ceil(baseWeight - (impacted * luckModifier));
+ } + }
+ lastLuck = luck; + LootPoolSingletonContainer.this.lastLuck = luck;
+ lastWeight = (int) Math.max(0, Math.floor(baseWeight)); + LootPoolSingletonContainer.this.lastWeight = (int) Math.max(Math.floor(baseWeight), 0);
+ return lastWeight; + return lastWeight;
} }
} }
+ private Float lastLuck = null; + private Float lastLuck = null;
+ private int lastWeight = 0; + private int lastWeight = 0;
+ // Paper end + // Paper end
}
@FunctionalInterface
protected interface EntryConstructor {

View File

@ -5,15 +5,15 @@ Subject: [PATCH] Print Error details when failing to save player data
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java 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 60fe01e824e4657d2601797d7858d5de339ab255..5b2a558d4d357d0de033ec2d7a9b4686f202c903 100644 index 7b367e273c2a6869f8d8929c24ee45efdf6d4b1e..6727468946ea5f60bd80549f827a7c2b9a42b98b 100644
--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java --- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
@@ -43,7 +43,7 @@ public class PlayerDataStorage { @@ -43,7 +43,7 @@ public class PlayerDataStorage {
Util.safeReplaceFile(file1, file, file2); Util.safeReplaceFile(file1, file, file2);
} catch (Exception exception) { } catch (Exception exception) {
- PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", entityhuman.getName().getString()); - PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getName().getString());
+ PlayerDataStorage.LOGGER.error("Failed to save player data for {}", entityhuman.getScoreboardName(), exception); // Paper + PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), exception); // Paper
} }
} }

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Make shield blocking delay configurable
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index e8e1e7dafaf1c105b2f58cf3e118e3d665dc50ec..3e4bd1d6718d3ad2498fe9bd72eaac45044ecb77 100644 index a0a846a2e60bdc17537bd697137f65321c1a61d8..e1110274a9f6b8f7007537732ec8eff7e72040ee 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -369,4 +369,9 @@ public class PaperWorldConfig { @@ -363,4 +363,9 @@ public class PaperWorldConfig {
disableEnderpearlExploit = getBoolean("game-mechanics.disable-unloaded-chunk-enderpearl-exploit", disableEnderpearlExploit); disableEnderpearlExploit = getBoolean("game-mechanics.disable-unloaded-chunk-enderpearl-exploit", disableEnderpearlExploit);
log("Disable Unloaded Chunk Enderpearl Exploit: " + (disableEnderpearlExploit ? "enabled" : "disabled")); log("Disable Unloaded Chunk Enderpearl Exploit: " + (disableEnderpearlExploit ? "enabled" : "disabled"));
} }
@ -19,10 +19,10 @@ index e8e1e7dafaf1c105b2f58cf3e118e3d665dc50ec..3e4bd1d6718d3ad2498fe9bd72eaac45
+ } + }
} }
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 8b0d1f4fbc43a6f37a5f9c453b5dd142a4f69745..af2e81137d9c686f8d94a1d0d7241619fa1f352c 100644 index 28de49c8b5771491b168bba26e6033669c48e3c9..a3af689df12852ac47bd658f28c9f5b9991d3301 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3308,7 +3308,7 @@ public abstract class LivingEntity extends Entity { @@ -3665,12 +3665,24 @@ public abstract class LivingEntity extends Entity {
if (this.isUsingItem() && !this.useItem.isEmpty()) { if (this.isUsingItem() && !this.useItem.isEmpty()) {
Item item = this.useItem.getItem(); Item item = this.useItem.getItem();
@ -31,10 +31,8 @@ index 8b0d1f4fbc43a6f37a5f9c453b5dd142a4f69745..af2e81137d9c686f8d94a1d0d7241619
} else { } else {
return false; return false;
} }
@@ -3587,4 +3587,15 @@ public abstract class LivingEntity extends Entity {
public void broadcastBreakEvent(InteractionHand hand) {
this.broadcastBreakEvent(hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND);
} }
+ // Paper start + // Paper start
+ public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay; + public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay;
+ +
@ -46,12 +44,15 @@ index 8b0d1f4fbc43a6f37a5f9c453b5dd142a4f69745..af2e81137d9c686f8d94a1d0d7241619
+ this.shieldBlockingDelay = shieldBlockingDelay; + this.shieldBlockingDelay = shieldBlockingDelay;
+ } + }
+ // Paper end + // Paper end
} +
public boolean isSuppressingSlidingDownLadder() {
return this.isShiftKeyDown();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 006f4c71bbcda61b55815e7ceab91731ab062da0..663887d9aecc2823fe7d02a9b108a291cd27102c 100644 index 4e9565def5a28a7391f8f541d066c2981d0bbc92..dea64f96139fbf4e1ff860b75f2005169a55c395 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -699,5 +699,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @@ -707,5 +707,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setArrowsStuck(int arrows) { public void setArrowsStuck(int arrows) {
getHandle().setArrowCount(arrows); getHandle().setArrowCount(arrows);
} }

View File

@ -0,0 +1,96 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 15 Jun 2013 19:51:17 -0400
Subject: [PATCH] Improve EntityShootBowEvent
Adds missing call to Illagers and also adds Arrow ItemStack to skeltons
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
index d7bca8fa71e325ba1967537d4102ccb207c4d717..3d8f3e22223e4effeaf52cb18c14c60276d4689c 100644
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -196,7 +196,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4));
// CraftBukkit start
- org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true);
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getPickupItem(), entityarrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper
if (event.isCancelled()) {
event.getProjectile().remove();
return;
diff --git a/src/main/java/net/minecraft/world/entity/monster/Illusioner.java b/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
index ff38ad2ac16ff49a290976e392175e96fa986925..c9fa01b910de7ecb494d3000afebea9a2bd1276a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Illusioner.java
@@ -196,8 +196,18 @@ public class Illusioner extends SpellcasterIllager implements RangedAttackMob {
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4));
+ // Paper start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getPickupItem(), entityarrow, target.getUsedItemHand(), 0.8F, true);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ this.level.addFreshEntity(entityarrow);
+ }
this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.level.addFreshEntity(entityarrow);
+ // Paper end
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
index 71f0de893fe0243cc226fd36685f2a3fba02575f..988986d549dae93cfcb8147126c84f263efe3452 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -586,7 +586,7 @@ public abstract class AbstractArrow extends Projectile {
}
}
- protected abstract ItemStack getPickupItem();
+ public abstract ItemStack getPickupItem(); // Paper - protected -> public
@Override
protected Entity.MovementEmission getMovementEmission() {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Arrow.java b/src/main/java/net/minecraft/world/entity/projectile/Arrow.java
index 1b71df52df1e1d408d2cdf5bef5fbea95fdced80..c0a3bfde24ef5e4b9c1bb1c0b8fbffdde3604513 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Arrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Arrow.java
@@ -244,7 +244,7 @@ public class Arrow extends AbstractArrow {
}
@Override
- protected ItemStack getPickupItem() {
+ public ItemStack getPickupItem() { // Paper - protected -> public
if (this.effects.isEmpty() && this.potion == Potions.EMPTY) {
return new ItemStack(Items.ARROW);
} else {
diff --git a/src/main/java/net/minecraft/world/entity/projectile/SpectralArrow.java b/src/main/java/net/minecraft/world/entity/projectile/SpectralArrow.java
index 4f62f72d125504602d4b0278119247d36d58b3c9..f6081e0fdf71d6b2b80c94f2ffd3395c08fb84a7 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/SpectralArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/SpectralArrow.java
@@ -36,7 +36,7 @@ public class SpectralArrow extends AbstractArrow {
}
@Override
- protected ItemStack getPickupItem() {
+ public ItemStack getPickupItem() { // Paper - protected -> public
return new ItemStack(Items.SPECTRAL_ARROW);
}
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
index 04c6c3bf372186182b91a03e11dba0495357393d..227cb0834a075cbe2db136bf6dc9820d2a04c458 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
@@ -98,7 +98,7 @@ public class ThrownTrident extends AbstractArrow {
}
@Override
- protected ItemStack getPickupItem() {
+ public ItemStack getPickupItem() { // Paper - protected -> public
return this.tridentItem.copy();
}

View File

@ -7,10 +7,10 @@ Called when a player is firing a bow and the server is choosing an arrow to use.
Plugins can skip selection of certain arrows and control which is used. Plugins can skip selection of certain arrows and control which is used.
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 552920f59aae9de2cad3edcdc8c48a91dff49093..b88d8f2c377322290002e84e217f3f2f6e4e71e8 100644 index a3f719d9dc63af9decc54a789f04595bb2d55710..a4bb172ed720869578575562738521e99a53acca 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -2139,6 +2139,17 @@ public abstract class Player extends LivingEntity { @@ -2186,6 +2186,17 @@ public abstract class Player extends LivingEntity {
return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING);
} }
@ -28,7 +28,7 @@ index 552920f59aae9de2cad3edcdc8c48a91dff49093..b88d8f2c377322290002e84e217f3f2f
@Override @Override
public ItemStack getProjectile(ItemStack stack) { public ItemStack getProjectile(ItemStack stack) {
if (!(stack.getItem() instanceof ProjectileWeaponItem)) { if (!(stack.getItem() instanceof ProjectileWeaponItem)) {
@@ -2155,7 +2166,7 @@ public abstract class Player extends LivingEntity { @@ -2202,7 +2213,7 @@ public abstract class Player extends LivingEntity {
for (int i = 0; i < this.inventory.getContainerSize(); ++i) { for (int i = 0; i < this.inventory.getContainerSize(); ++i) {
ItemStack itemstack2 = this.inventory.getItem(i); ItemStack itemstack2 = this.inventory.getItem(i);

View File

@ -6,50 +6,49 @@ Subject: [PATCH] Implement EntityKnockbackByEntityEvent
This event is called when an entity receives knockback by another entity. This event is called when an entity receives knockback by another entity.
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index af2e81137d9c686f8d94a1d0d7241619fa1f352c..04489a915d11ba970a5188a5a913432ab4ef9faa 100644 index a3af689df12852ac47bd658f28c9f5b9991d3301..acf6f04fa229fb0850217ff3d50bf3b8c16cafdf 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1336,7 +1336,7 @@ public abstract class LivingEntity extends Entity { @@ -1437,7 +1437,7 @@ public abstract class LivingEntity extends Entity {
} }
this.hurtDir = (float) (Mth.atan2(d1, d0) * 57.2957763671875D - (double) this.yRot); this.hurtDir = (float) (Mth.atan2(d1, d0) * 57.2957763671875D - (double) this.getYRot());
- this.knockback(0.4F, d0, d1); - this.knockback(0.4000000059604645D, d0, d1);
+ this.doKnockback(0.4F, d0, d1, entity1); // Paper + this.knockback(0.4000000059604645D, d0, d1, entity1);
} else { } else {
this.hurtDir = (float) ((int) (Math.random() * 2.0D) * 180); this.hurtDir = (float) ((int) (Math.random() * 2.0D) * 180);
} }
@@ -1384,7 +1384,7 @@ public abstract class LivingEntity extends Entity { @@ -1485,7 +1485,7 @@ public abstract class LivingEntity extends Entity {
} }
protected void blockedByShield(LivingEntity target) { protected void blockedByShield(LivingEntity target) {
- target.knockback(0.5F, target.getX() - this.getX(), target.getZ() - this.getZ()); - target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ());
+ target.doKnockback(0.5F, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper + target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this);
} }
private boolean checkTotemDeathProtection(DamageSource source) { private boolean checkTotemDeathProtection(DamageSource source) {
@@ -1627,6 +1627,11 @@ public abstract class LivingEntity extends Entity { @@ -1733,6 +1733,11 @@ public abstract class LivingEntity extends Entity {
} }
public void knockback(float f, double d0, double d1) { public void knockback(double strength, double x, double z) {
+ // Paper start - add knockbacking entity parameter + // Paper start - add knockbacking entity parameter
+ this.doKnockback(f, d0, d1, null); + this.knockback(strength, x, z, null);
+ } + }
+ public void doKnockback(float f, double d0, double d1, Entity knockingBackEntity) { + public void knockback(double strength, double x, double z, Entity knockingBackEntity) {
+ // Paper end - add knockbacking entity parameter + // Paper end - add knockbacking entity parameter
f = (float) ((double) f * (1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE))); strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
if (f > 0.0F) { if (strength > 0.0D) {
this.hasImpulse = true; this.hasImpulse = true;
@@ -1634,6 +1639,16 @@ public abstract class LivingEntity extends Entity { @@ -1740,6 +1745,15 @@ public abstract class LivingEntity extends Entity {
Vec3 vec3d1 = (new Vec3(d0, 0.0D, d1)).normalize().scale((double) f); Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength);
this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround ? Math.min(0.4D, vec3d.y / 2.0D + (double) f) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
+
+ // Paper start - call EntityKnockbackByEntityEvent + // Paper start - call EntityKnockbackByEntityEvent
+ Vec3 currentMot = this.getDeltaMovement(); + Vec3 currentMovement = this.getDeltaMovement();
+ org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMot.x - vec3d.x, currentMot.y - vec3d.y, currentMot.z - vec3d.z); + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z);
+ // Restore old velocity to be able to access it in the event + // Restore old velocity to be able to access it in the event
+ this.setDeltaMovement(vec3d); + this.setDeltaMovement(vec3d);
+ if (knockingBackEntity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), knockingBackEntity.getBukkitEntity(), f, delta).callEvent()) { + if (knockingBackEntity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), knockingBackEntity.getBukkitEntity(), (float) strength, delta).callEvent()) {
+ this.setDeltaMovement(vec3d.x + delta.getX(), vec3d.y + delta.getY(), vec3d.z + delta.getZ()); + this.setDeltaMovement(vec3d.x + delta.getX(), vec3d.y + delta.getY(), vec3d.z + delta.getZ());
+ } + }
+ // Paper end + // Paper end
@ -57,37 +56,37 @@ index af2e81137d9c686f8d94a1d0d7241619fa1f352c..04489a915d11ba970a5188a5a913432a
} }
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index eb35c69bb777ba8d83b2304ff9f862512643e745..f3690ea49cf90c816b8b3554b47d6f2d9dfbe016 100644 index 2ed756c73b0cfddb559126d85316f37c3f958c0c..8451baff82cb7ec7615ab50a409724897ccf4d95 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1566,7 +1566,7 @@ public abstract class Mob extends LivingEntity { @@ -1532,7 +1532,7 @@ public abstract class Mob extends LivingEntity {
if (flag) { if (flag) {
if (f1 > 0.0F && target instanceof LivingEntity) { if (f1 > 0.0F && target instanceof LivingEntity) {
- ((LivingEntity) target).knockback(f1 * 0.5F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F))); - ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ ((LivingEntity) target).doKnockback(f1 * 0.5F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F)), this); // Paper + ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 b88d8f2c377322290002e84e217f3f2f6e4e71e8..5e6a86b0b8999a5c47d2f9bdd9857ab5f0772033 100644 index a4bb172ed720869578575562738521e99a53acca..0d6e024208182d5779be3d84cff193ce904ad541 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1174,7 +1174,7 @@ public abstract class Player extends LivingEntity { @@ -1234,7 +1234,7 @@ public abstract class Player extends LivingEntity {
if (flag5) { if (flag5) {
if (i > 0) { if (i > 0) {
if (target instanceof LivingEntity) { if (target instanceof LivingEntity) {
- ((LivingEntity) target).knockback((float) i * 0.5F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F))); - ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ ((LivingEntity) target).doKnockback((float) i * 0.5F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F)), this); // Paper + ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
} else { } else {
target.push((double) (-Mth.sin(this.yRot * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.yRot * 0.017453292F) * (float) i * 0.5F)); target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F));
} }
@@ -1198,7 +1198,7 @@ public abstract class Player extends LivingEntity { @@ -1258,7 +1258,7 @@ public abstract class Player extends LivingEntity {
if (entityliving != this && entityliving != target && !this.isAlliedTo(entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { if (entityliving != this && entityliving != target && !this.isAlliedTo(entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
// CraftBukkit start - Only apply knockback if the damage hits // CraftBukkit start - Only apply knockback if the damage hits
if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) { if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) {
- entityliving.knockback(0.4F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F))); - entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
+ entityliving.doKnockback(0.4F, (double) Mth.sin(this.yRot * 0.017453292F), (double) (-Mth.cos(this.yRot * 0.017453292F)), this); // Paper + entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
} }
// CraftBukkit end // CraftBukkit end
} }

View File

@ -6,14 +6,15 @@ Subject: [PATCH] Expand Explosions API
Add Entity as a Source capability, and add more API choices, and on Location. Add Entity as a Source capability, and add more API choices, and on Location.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 2dc9daaeea600fff1f2efddf74b6849fd745a28c..9b5a1c3ab8ffde524e194fdeaa8eaef6b286b57b 100644 index 058346b89c07d44a5425a61abedcfc440cb9ee21..df6b4f65dd84621b8477b42a504f9e62c633a6b5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -871,6 +871,11 @@ public class CraftWorld implements World { @@ -889,6 +889,12 @@ public class CraftWorld implements World {
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) {
return !world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.BlockInteraction.BREAK : Explosion.BlockInteraction.NONE).wasCanceled; return !this.world.explode(source == null ? null : ((CraftEntity) source).getHandle(), x, y, z, power, setFire, breakBlocks ? Explosion.BlockInteraction.BREAK : Explosion.BlockInteraction.NONE).wasCanceled;
} }
+ // Paper start + // Paper start
+ @Override
+ public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { + public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) {
+ return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? Explosion.BlockInteraction.BREAK : Explosion.BlockInteraction.NONE).wasCanceled; + return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? Explosion.BlockInteraction.BREAK : Explosion.BlockInteraction.NONE).wasCanceled;
+ } + }

View File

@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Jun 2018 00:21:28 -0400
Subject: [PATCH] LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index dea64f96139fbf4e1ff860b75f2005169a55c395..5194da5a141718390a317d75b31205f951cec7a2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -717,5 +717,30 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void setShieldBlockingDelay(int delay) {
getHandle().setShieldBlockingDelay(delay);
}
+
+ @Override
+ public ItemStack getActiveItem() {
+ return getHandle().getUseItem().asBukkitMirror();
+ }
+
+ @Override
+ public int getItemUseRemainingTime() {
+ return getHandle().getUseItemRemainingTicks();
+ }
+
+ @Override
+ public int getHandRaisedTime() {
+ return getHandle().getTicksUsingItem();
+ }
+
+ @Override
+ public boolean isHandRaised() {
+ return getHandle().isUsingItem();
+ }
+
+ @Override
+ public org.bukkit.inventory.EquipmentSlot getHandRaised() {
+ return getHandle().getUsedItemHand() == net.minecraft.world.InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND;
+ }
// Paper end
}

View File

@ -32,13 +32,13 @@ index 0000000000000000000000000000000000000000..e75e1d0d833c96af139fd955b2585ec2
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java b/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java diff --git a/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java b/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java
index b3ad4d54eeb1b894c24a5a76e8b12b8d9568cd56..ae10f3933fe78f74995952a6a8acf09ef4e99823 100644 index 6c3162606ccf799e99d591da33fd649847db54b8..7ff5d0410ac281da20a031e748e8c15f3156d809 100644
--- a/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java --- a/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java
+++ b/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java +++ b/src/main/java/net/minecraft/world/entity/monster/RangedAttackMob.java
@@ -4,5 +4,8 @@ import net.minecraft.world.entity.LivingEntity; @@ -3,5 +3,8 @@ package net.minecraft.world.entity.monster;
import net.minecraft.world.entity.LivingEntity;
public interface RangedAttackMob { public interface RangedAttackMob {
- void performRangedAttack(LivingEntity target, float pullProgress); - void performRangedAttack(LivingEntity target, float pullProgress);
+ void performRangedAttack(LivingEntity target, float pullProgress); default void rangedAttack(LivingEntity entityliving, float f) { performRangedAttack(entityliving, f); } // Paper - OBFHELPER + void performRangedAttack(LivingEntity target, float pullProgress); default void rangedAttack(LivingEntity entityliving, float f) { performRangedAttack(entityliving, f); } // Paper - OBFHELPER
+ +
@ -72,27 +72,20 @@ index 59b866e54e0d7e1dd8815ffa85275e36271113da..bbf7189a0fc9921e7a6007494f91229d
public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner entity) { public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner entity) {
super(server, entity); super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
index 04f716af67939b2dc34875f722816dd1ffdc4966..ed3b8fcc221d6c0789eb92eb4716d640ba0fec9f 100644 index bda998c9e621bd9bca6642bfa86befed08f4902b..6ad12711a82d7be42ba41c0428779f86536fd900 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
@@ -1,5 +1,6 @@ @@ -9,7 +9,7 @@ import org.bukkit.entity.Llama;
package org.bukkit.craftbukkit.entity;
+import com.destroystokyo.paper.entity.CraftRangedEntity;
import com.google.common.base.Preconditions;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventoryLlama;
@@ -9,7 +10,7 @@ import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color; import org.bukkit.entity.Llama.Color;
import org.bukkit.inventory.LlamaInventory; import org.bukkit.inventory.LlamaInventory;
-public class CraftLlama extends CraftChestedHorse implements Llama { -public class CraftLlama extends CraftChestedHorse implements Llama {
+public class CraftLlama extends CraftChestedHorse implements Llama, CraftRangedEntity<net.minecraft.world.entity.animal.horse.Llama> { // Paper +public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.animal.horse.Llama> { // Paper
public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) { public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) {
super(server, entity); super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
index 12bce49fcb164b6311a81024d1749a582ab1be25..c06fea6e0eaf58b8e7441ccf8595d6ca8417526a 100644 index 27763d1eca832abda76c8b3c22595cbaf9b1fe45..aeda5fc001fe4ce55ee467240b275b6050a29f98 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.EntityType; @@ -13,7 +13,7 @@ import org.bukkit.entity.EntityType;
@ -105,7 +98,7 @@ index 12bce49fcb164b6311a81024d1749a582ab1be25..c06fea6e0eaf58b8e7441ccf8595d6ca
public CraftPiglin(CraftServer server, net.minecraft.world.entity.monster.piglin.Piglin entity) { public CraftPiglin(CraftServer server, net.minecraft.world.entity.monster.piglin.Piglin entity) {
super(server, entity); super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
index fc86b8ecc349ed59c9eb6de03086d4027cb4e08d..949260d6750e71f148229955c94bcbaad9d54a2d 100644 index 06786fba1fef36e8fc3d0f5650160123f728a6d1..beea227855f0b978e655efc298024120df8f4945 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
@@ -6,7 +6,7 @@ import org.bukkit.entity.EntityType; @@ -6,7 +6,7 @@ import org.bukkit.entity.EntityType;
@ -131,7 +124,7 @@ index 4cd3dfd3466f384aab06dacd388e8053b045b046..b2d3244cca4d9d108159f3537d8a9aac
public CraftSkeleton(CraftServer server, AbstractSkeleton entity) { public CraftSkeleton(CraftServer server, AbstractSkeleton entity) {
super(server, entity); super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
index fcce4aa391d0c448531815e99e0e32c84203c1b8..a7164a921f479c928049d4e812eab50567e96fc2 100644 index 6a82d567d96a42bfea0e38afb4e8de13eb3ad5a2..659e2959c5330e4764ea1edc7f8de9f464f9ff52 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
@ -157,7 +150,7 @@ index 60e00e539d214eb8854a53364c92c3cf55ca1062..d4eeb071dbbfca3ecea256228853bcb5
super(server, entity); super(server, entity);
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
index 728a8c0f5781f33bdb096aefb569e9509dda8c89..fdcd680b972da54f9cdb41dff5563e42bd12d8e3 100644 index 54a7defa85542765f3dd0d7ccb770dafd9c7d484..640b0860fbe3412da32d03187e6f355ba8f099ea 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
@@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.boss.CraftBossBar; @@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.boss.CraftBossBar;

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add config to disable ender dragon legacy check
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 3e4bd1d6718d3ad2498fe9bd72eaac45044ecb77..4813f62d1e382d5ac6971b2244df3f13c80d1950 100644 index e1110274a9f6b8f7007537732ec8eff7e72040ee..8f8a3ea51823a9cfba985efeb7e320ae42e0da8a 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -374,4 +374,9 @@ public class PaperWorldConfig { @@ -368,4 +368,9 @@ public class PaperWorldConfig {
private void shieldBlockingDelay() { private void shieldBlockingDelay() {
shieldBlockingDelay = getInt("game-mechanics.shield-blocking-delay", 5); shieldBlockingDelay = getInt("game-mechanics.shield-blocking-delay", 5);
} }
@ -19,15 +19,17 @@ index 3e4bd1d6718d3ad2498fe9bd72eaac45044ecb77..4813f62d1e382d5ac6971b2244df3f13
+ } + }
} }
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 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 2386ffeec60851ba192b89bc6fd7ffff9c56aff5..4b18931225ef60dbcffd7fcc20d0e9ce62348a07 100644 index 758af2c2d66073aeaee766adb672c465d2993eab..711be01abe9d47bdc9bfe8b09a2719d666b986fb 100644
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java --- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
@@ -73,7 +73,7 @@ public class EndDragonFight { @@ -84,6 +84,10 @@ public class EndDragonFight {
private boolean dragonKilled; private List<EndCrystal> respawnCrystals;
private boolean previouslyKilled;
public UUID dragonUUID; public EndDragonFight(ServerLevel world, long gatewaysSeed, CompoundTag nbt) {
- private boolean needsStateScanning; + // Paper start
+ private boolean needsStateScanning; private void setScanForLegacyFight(boolean scanForLegacyFight) { this.needsStateScanning = scanForLegacyFight; } private boolean scanForLegacyFight() { return this.needsStateScanning; } // Paper - OBFHELPER + this.needsStateScanning = world.paperConfig.scanForLegacyEnderDragon;
public BlockPos portalLocation; + if (!this.needsStateScanning) this.dragonKilled = true;
public DragonRespawnAnimation respawnStage; + // Paper end
private int respawnTime; this.level = world;
if (nbt.contains("NeedsStateScanning")) {
this.needsStateScanning = nbt.getBoolean("NeedsStateScanning");

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Implement World.getEntity(UUID) API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 9b5a1c3ab8ffde524e194fdeaa8eaef6b286b57b..3a3466cd9bbd34dbc0b79567f5579e84a81d6009 100644 index df6b4f65dd84621b8477b42a504f9e62c633a6b5..e7f5cd35869790baf616e6c65f49169aa5349e89 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1286,6 +1286,15 @@ public class CraftWorld implements World { @@ -1295,6 +1295,15 @@ public class CraftWorld implements World {
return list; return list;
} }

View File

@ -7,10 +7,10 @@ Allows you to determine why an inventory was closed, enabling plugin developers
to "confirm" things based on if it was player triggered close or not. to "confirm" things based on if it was player triggered close or not.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 5110f2c70d96284e8e7592b3d89266b867b9a466..ea1b15495481157912140bf5de9bf4a949c16910 100644 index cf074ef0cb01bc2cbd8c529e7233ceb9443f764d..ca0907601c6262d27c3406cea806a40421bc4ace 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1119,7 +1119,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl @@ -1055,7 +1055,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
for (BlockEntity tileentity : chunk.getBlockEntities().values()) { for (BlockEntity tileentity : chunk.getBlockEntities().values()) {
if (tileentity instanceof net.minecraft.world.Container) { if (tileentity instanceof net.minecraft.world.Container) {
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
@ -19,20 +19,20 @@ index 5110f2c70d96284e8e7592b3d89266b867b9a466..ea1b15495481157912140bf5de9bf4a9
} }
} }
} }
@@ -1177,7 +1177,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl @@ -1937,7 +1937,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
// Spigot Start // Spigot Start
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder) { if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder) {
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) { for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) {
- h.closeInventory(); - h.closeInventory();
+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper + h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
}
} }
} // Spigot End
// Spigot End
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0fa977a31cf945b74f3a046b6be302b10f494ad1..1441a461e749dbfa303095f6b51d655c45f68ce0 100644 index 7159a433e9a264d2151dddc84a74689d0bc7635b..171500918c8ee248689909ae97230eb18adc33e5 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -544,7 +544,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -602,7 +602,7 @@ public class ServerPlayer extends Player {
} }
// Paper end // Paper end
if (!this.level.isClientSide && !this.containerMenu.stillValid(this)) { if (!this.level.isClientSide && !this.containerMenu.stillValid(this)) {
@ -41,7 +41,7 @@ index 0fa977a31cf945b74f3a046b6be302b10f494ad1..1441a461e749dbfa303095f6b51d655c
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
@@ -717,7 +717,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -754,7 +754,7 @@ public class ServerPlayer extends Player {
// SPIGOT-943 - only call if they have an inventory open // SPIGOT-943 - only call if they have an inventory open
if (this.containerMenu != this.inventoryMenu) { if (this.containerMenu != this.inventoryMenu) {
@ -50,7 +50,7 @@ index 0fa977a31cf945b74f3a046b6be302b10f494ad1..1441a461e749dbfa303095f6b51d655c
} }
net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure
@@ -1290,7 +1290,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -1341,7 +1341,7 @@ public class ServerPlayer extends Player {
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
if (this.containerMenu != this.inventoryMenu) { if (this.containerMenu != this.inventoryMenu) {
@ -59,7 +59,7 @@ index 0fa977a31cf945b74f3a046b6be302b10f494ad1..1441a461e749dbfa303095f6b51d655c
} }
this.nextContainerCounter(); this.nextContainerCounter();
@@ -1350,7 +1350,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -1401,7 +1401,7 @@ public class ServerPlayer extends Player {
} }
// CraftBukkit end // CraftBukkit end
if (this.containerMenu != this.inventoryMenu) { if (this.containerMenu != this.inventoryMenu) {
@ -68,22 +68,23 @@ index 0fa977a31cf945b74f3a046b6be302b10f494ad1..1441a461e749dbfa303095f6b51d655c
} }
// this.nextContainerCounter(); // CraftBukkit - moved up // this.nextContainerCounter(); // CraftBukkit - moved up
@@ -1414,7 +1414,12 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -1430,7 +1430,13 @@ public class ServerPlayer extends Player {
@Override @Override
public void closeContainer() { public void closeContainer() {
- CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit - CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
+ // Paper start + // Paper start
+ closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNKNOWN); + this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNKNOWN);
+ } + }
+ public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + @Override
+ public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit
+ // Paper end + // Paper end
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
this.doCloseContainer(); this.doCloseContainer();
} }
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index fb36aa08cd2fbe3f7262dccb8cf0f7cae55aea9c..d322e99170b3cb6594efc824a879ab9a538ea1eb 100644 index 35a00a622ff0c3582e08dbbefb1d34a84e590a81..ce88f701f296e67afc67d7e3882406e86147408e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -188,6 +188,7 @@ import org.bukkit.event.inventory.ClickType; @@ -188,6 +188,7 @@ import org.bukkit.event.inventory.ClickType;
@ -94,7 +95,7 @@ index fb36aa08cd2fbe3f7262dccb8cf0f7cae55aea9c..d322e99170b3cb6594efc824a879ab9a
import org.bukkit.event.inventory.InventoryCreativeEvent; import org.bukkit.event.inventory.InventoryCreativeEvent;
import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.inventory.SmithItemEvent; import org.bukkit.event.inventory.SmithItemEvent;
@@ -2309,10 +2310,15 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -2332,10 +2333,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override @Override
public void handleContainerClose(ServerboundContainerClosePacket packet) { public void handleContainerClose(ServerboundContainerClosePacket packet) {
@ -113,10 +114,10 @@ index fb36aa08cd2fbe3f7262dccb8cf0f7cae55aea9c..d322e99170b3cb6594efc824a879ab9a
this.player.doCloseContainer(); this.player.doCloseContainer();
} }
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index ae60b233c4d56a4964b388f96e9cc66410774e8d..51b1ce465d23b971f7e08a3175319a33183d0398 100644 index 429e6c7f9a5e5355e26deeae1e89ffea7439cd96..7c5a75fb34640bb4e7ef839412dbb30b0d0fc8e8 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -490,7 +490,7 @@ public abstract class PlayerList { @@ -494,7 +494,7 @@ public abstract class PlayerList {
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
// See SPIGOT-5799, SPIGOT-6145 // See SPIGOT-5799, SPIGOT-6145
if (entityplayer.containerMenu != entityplayer.inventoryMenu) { if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
@ -124,12 +125,12 @@ index ae60b233c4d56a4964b388f96e9cc66410774e8d..51b1ce465d23b971f7e08a3175319a33
+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper + entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
} }
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName()))); PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, com.destroystokyo.paper.PaperConfig.useDisplayNameInQuit ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())));
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java 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 5e6a86b0b8999a5c47d2f9bdd9857ab5f0772033..709e930eef7bae5694238ed8c4d0ef59316bb715 100644 index 0d6e024208182d5779be3d84cff193ce904ad541..e0e33dd92b686939f622f0a7da0d5a971f43d0d6 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -249,7 +249,7 @@ public abstract class Player extends LivingEntity { @@ -264,7 +264,7 @@ public abstract class Player extends LivingEntity {
this.updateIsUnderwater(); this.updateIsUnderwater();
super.tick(); super.tick();
if (!this.level.isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) { if (!this.level.isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) {
@ -138,12 +139,12 @@ index 5e6a86b0b8999a5c47d2f9bdd9857ab5f0772033..709e930eef7bae5694238ed8c4d0ef59
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
@@ -444,6 +444,13 @@ public abstract class Player extends LivingEntity { @@ -487,6 +487,13 @@ public abstract class Player extends LivingEntity {
return 20;
} }
+ // Paper start - unused code, but to keep signatures aligned + // Paper start - unused code, but to keep signatures aligned
+ public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ closeContainer(); + closeContainer();
+ this.containerMenu = this.inventoryMenu; + this.containerMenu = this.inventoryMenu;
+ } + }
@ -153,26 +154,29 @@ index 5e6a86b0b8999a5c47d2f9bdd9857ab5f0772033..709e930eef7bae5694238ed8c4d0ef59
this.containerMenu = this.inventoryMenu; this.containerMenu = this.inventoryMenu;
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 4aec1c2b26d48cb5bea3dfb9e183526763bdb98f..a73c6ddd6bf66cc21ae5b25daacdece8cbfeeeac 100644 index 7f7322b5174a7580675b0607b0f282f7bf75a3e2..662a4cec1d292428f06ec5a1f862a1f8d8834c09 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -374,7 +374,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -373,7 +373,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
if (((ServerPlayer) getHandle()).connection == null) return; if (((ServerPlayer) this.getHandle()).connection == null) return;
if (getHandle().containerMenu != getHandle().inventoryMenu) { if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
// fire INVENTORY_CLOSE if one already open // fire INVENTORY_CLOSE if one already open
- ((ServerPlayer) getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(getHandle().containerMenu.containerId)); - ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId));
+ ((ServerPlayer) getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper + ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper
} }
ServerPlayer player = (ServerPlayer) getHandle(); ServerPlayer player = (ServerPlayer) this.getHandle();
AbstractContainerMenu container; AbstractContainerMenu container;
@@ -444,8 +444,13 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @@ -443,8 +443,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override @Override
public void closeInventory() { public void closeInventory() {
- getHandle().closeContainer(); - this.getHandle().closeContainer();
+ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN);
+ getHandle().closeContainer();
+ // Paper start + // Paper start
+ getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN); + getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN);
} }
+ @Override
+ public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
+ getHandle().closeContainer(reason); + getHandle().closeContainer(reason);
+ } + }
@ -181,23 +185,23 @@ index 4aec1c2b26d48cb5bea3dfb9e183526763bdb98f..a73c6ddd6bf66cc21ae5b25daacdece8
@Override @Override
public boolean isBlocking() { public boolean isBlocking() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 46338fe5693003698de9c7b37a860c3481e06233..c7f66dddf0a0850ca4048dd47cd2ded114caa07e 100644 index 8df1894df3583840412ccc7ccdc4b23db6dd6265..f8155d7edb4e13c2ec5ed832231f02ee6eff3f35 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -895,7 +895,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -908,7 +908,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Close any foreign inventory // Close any foreign inventory
if (getHandle().containerMenu != getHandle().inventoryMenu) { if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) {
- getHandle().closeContainer(); - this.getHandle().closeContainer();
+ getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper + this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper
} }
// Check if the fromWorld and toWorld are the same. // Check if the fromWorld and toWorld are the same.
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 5e8ff18f98b03741ccbb927f87499ae36d775a86..c2f58b95db41b2205fbf2728c6a99419c6a63dfa 100644 index 56900b5810db623a49559ad218a5385c110bf479..375e9e45331d5be237c67f11af94c6998409418b 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1175,7 +1175,7 @@ public class CraftEventFactory { @@ -1154,7 +1154,7 @@ public class CraftEventFactory {
public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) {
if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open
@ -206,7 +210,7 @@ index 5e8ff18f98b03741ccbb927f87499ae36d775a86..c2f58b95db41b2205fbf2728c6a99419
} }
CraftServer server = player.level.getCraftServer(); CraftServer server = player.level.getCraftServer();
@@ -1341,8 +1341,18 @@ public class CraftEventFactory { @@ -1320,8 +1320,18 @@ public class CraftEventFactory {
return event; return event;
} }