SPIGOT-5195: Player loot table does not drop when keepInventory is on

This commit is contained in:
md_5 2019-07-22 12:12:48 +10:00
parent 8b09d98319
commit 6da0abca08

View file

@ -231,7 +231,7 @@
scoreboardscore.setScore(i);
});
}
@@ -353,9 +492,47 @@
@@ -353,9 +492,46 @@
@Override
public void die(DamageSource damagesource) {
boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES);
@ -248,17 +248,16 @@
+ loot.add(CraftItemStack.asCraftMirror(item));
+ }
+ }
+ }
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
+ this.a(damagesource, this.lastDamageByPlayerTime > 0);
+ for (org.bukkit.inventory.ItemStack item : this.drops) {
+ loot.add(item);
+ }
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
- if (flag) {
- IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage();
+ // SPIGOT-5071: manually add player loot tables
+ this.a(damagesource, this.lastDamageByPlayerTime > 0);
+ for (org.bukkit.inventory.ItemStack item : this.drops) {
+ loot.add(item);
+ }
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
+ }
+
+ IChatBaseComponent defaultMessage = this.getCombatTracker().getDeathMessage();
+
+ String deathmessage = defaultMessage.getString();
@ -281,7 +280,7 @@
this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> {
if (!future.isSuccess()) {
@@ -386,11 +563,16 @@
@@ -386,11 +562,16 @@
}
this.releaseShoulderEntities();
@ -301,7 +300,7 @@
EntityLiving entityliving = this.getKillingEntity();
if (entityliving != null) {
@@ -433,10 +615,12 @@
@@ -433,10 +614,12 @@
String s = this.getName();
String s1 = entity.getName();
@ -316,7 +315,7 @@
} else {
this.a(StatisticList.MOB_KILLS);
}
@@ -454,7 +638,8 @@
@@ -454,7 +637,8 @@
int i = scoreboardteam.getColor().b();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -326,7 +325,7 @@
}
}
@@ -498,16 +683,26 @@
@@ -498,16 +682,26 @@
}
private boolean canPvP() {
@ -356,7 +355,7 @@
this.decouple();
this.getWorldServer().removePlayer(this);
if (!this.viewingCredits) {
@@ -520,10 +715,12 @@
@@ -520,10 +714,12 @@
} else {
WorldServer worldserver = this.server.getWorldServer(dimensionmanager1);
@ -370,7 +369,7 @@
this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, worlddata.getType(), this.playerInteractManager.getGameMode()));
this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
PlayerList playerlist = this.server.getPlayerList();
@@ -531,6 +728,8 @@
@@ -531,6 +727,8 @@
playerlist.d(this);
worldserver.removePlayer(this);
this.dead = false;
@ -379,7 +378,7 @@
double d0 = this.locX;
double d1 = this.locY;
double d2 = this.locZ;
@@ -540,6 +739,7 @@
@@ -540,6 +738,7 @@
float f2 = f1;
worldserver.getMethodProfiler().enter("moving");
@ -387,7 +386,7 @@
if (dimensionmanager1 == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) {
this.cu = new Vec3D(this.locX, this.locY, this.locZ);
d0 /= 8.0D;
@@ -557,6 +757,52 @@
@@ -557,6 +756,52 @@
f = 0.0F;
}
@ -440,7 +439,7 @@
this.setPositionRotation(d0, d1, d2, f1, f);
worldserver.getMethodProfiler().exit();
worldserver.getMethodProfiler().enter("placing");
@@ -568,12 +814,13 @@
@@ -568,12 +813,13 @@
d0 = MathHelper.a(d0, d4, d6);
d2 = MathHelper.a(d2, d5, d7);
this.setPositionRotation(d0, d1, d2, f1, f);
@ -455,7 +454,7 @@
for (int l = -2; l <= 2; ++l) {
for (int i1 = -2; i1 <= 2; ++i1) {
@@ -583,11 +830,20 @@
@@ -583,11 +829,20 @@
int i2 = k + i1 * 0 - l * 1;
boolean flag2 = j1 < 0;
@ -477,7 +476,7 @@
this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F);
this.setMot(Vec3D.a);
} else if (!worldserver1.getTravelAgent().a(this, f2)) {
@@ -616,11 +872,16 @@
@@ -616,11 +871,16 @@
this.lastSentExp = -1;
this.lastHealthSent = -1.0F;
this.lastFoodSent = -1;
@ -495,7 +494,7 @@
DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager();
DimensionManager dimensionmanager1 = this.world.worldProvider.getDimensionManager();
@@ -657,9 +918,16 @@
@@ -657,9 +917,16 @@
this.activeContainer.c();
}
@ -514,7 +513,7 @@
this.a(StatisticList.SLEEP_IN_BED);
CriterionTriggers.q.a(this);
});
@@ -667,6 +935,7 @@
@@ -667,6 +934,7 @@
@Override
public void wakeup(boolean flag, boolean flag1, boolean flag2) {
@ -522,7 +521,7 @@
if (this.isSleeping()) {
this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2));
}
@@ -754,8 +1023,9 @@
@@ -754,8 +1022,9 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
}
@ -533,7 +532,7 @@
}
@Override
@@ -770,6 +1040,17 @@
@@ -770,6 +1039,17 @@
this.nextContainerCounter();
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
@ -551,7 +550,7 @@
if (container == null) {
if (this.isSpectator()) {
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
@@ -777,9 +1058,11 @@
@@ -777,9 +1057,11 @@
return OptionalInt.empty();
} else {
@ -565,7 +564,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -792,13 +1075,24 @@
@@ -792,13 +1074,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -592,7 +591,7 @@
this.activeContainer.addSlotListener(this);
}
@@ -843,6 +1137,11 @@
@@ -843,6 +1136,11 @@
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@ -604,7 +603,7 @@
}
@Override
@@ -852,6 +1151,7 @@
@@ -852,6 +1150,7 @@
@Override
public void closeInventory() {
@ -612,7 +611,7 @@
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.m();
}
@@ -886,7 +1186,7 @@
@@ -886,7 +1185,7 @@
@Override
public void a(Statistic<?> statistic, int i) {
this.serverStatisticManager.b(this, statistic, i);
@ -621,7 +620,7 @@
scoreboardscore.addScore(i);
});
}
@@ -894,7 +1194,7 @@
@@ -894,7 +1193,7 @@
@Override
public void a(Statistic<?> statistic) {
this.serverStatisticManager.setStatistic(this, statistic, 0);
@ -630,7 +629,7 @@
}
@Override
@@ -943,7 +1243,16 @@
@@ -943,7 +1242,16 @@
public void triggerHealthUpdate() {
this.lastHealthSent = -1.0E8F;
@ -647,7 +646,7 @@
@Override
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -998,12 +1307,14 @@
@@ -998,12 +1306,14 @@
this.lastSentExp = -1;
this.lastHealthSent = -1.0F;
this.lastFoodSent = -1;
@ -663,7 +662,7 @@
}
@Override
@@ -1065,6 +1376,18 @@
@@ -1065,6 +1375,18 @@
@Override
public void a(EnumGamemode enumgamemode) {
@ -682,7 +681,7 @@
this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) {
@@ -1115,6 +1438,17 @@
@@ -1115,6 +1437,17 @@
}
public void a(PacketPlayInSettings packetplayinsettings) {
@ -700,7 +699,7 @@
this.locale = packetplayinsettings.b();
this.ck = packetplayinsettings.d();
this.cl = packetplayinsettings.e();
@@ -1151,13 +1485,13 @@
@@ -1151,13 +1484,13 @@
if (entity instanceof EntityHuman) {
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()}));
} else {
@ -716,7 +715,7 @@
}
@Override
@@ -1181,7 +1515,7 @@
@@ -1181,7 +1514,7 @@
this.spectatedEntity = (Entity) (entity == null ? this : entity);
if (entity1 != this.spectatedEntity) {
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
@ -725,7 +724,7 @@
}
}
@@ -1210,7 +1544,7 @@
@@ -1210,7 +1543,7 @@
@Nullable
public IChatBaseComponent getPlayerListName() {
@ -734,7 +733,7 @@
}
@Override
@@ -1228,21 +1562,33 @@
@@ -1228,21 +1561,33 @@
}
public void J() {
@ -768,7 +767,7 @@
if (worldserver == this.world) {
this.playerConnection.a(d0, d1, d2, f, f1);
} else {
@@ -1265,6 +1611,9 @@
@@ -1265,6 +1610,9 @@
this.server.getPlayerList().a(this, worldserver);
this.server.getPlayerList().updateClient(this);
}
@ -778,7 +777,7 @@
}
@@ -1316,4 +1665,144 @@
@@ -1316,4 +1664,144 @@
return entityitem;
}
}