Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
[ci skip] Add more patch identifying comments
Dieser Commit ist enthalten in:
Ursprung
8c8862f3a8
Commit
e84621a9d8
@ -9,7 +9,7 @@ on dropping the item instead of generalizing it for all dropped
|
||||
items like CB does.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 3ca06c5dfed3bc2006bf2f42444353bfab14096d..be05a52be037042c6158100e2ce880b8ed415d53 100644
|
||||
index 3ca06c5dfed3bc2006bf2f42444353bfab14096d..a3037dccab32597aa99e1590e1ea42fcec06bb0c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -944,22 +944,20 @@ public class ServerPlayer extends Player {
|
||||
@ -17,14 +17,14 @@ index 3ca06c5dfed3bc2006bf2f42444353bfab14096d..be05a52be037042c6158100e2ce880b8
|
||||
return;
|
||||
}
|
||||
- java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.getInventory().getContainerSize());
|
||||
+ List<DefaultDrop> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper
|
||||
+ List<DefaultDrop> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior
|
||||
boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
|
||||
|
||||
if (!keepInventory) {
|
||||
for (ItemStack item : this.getInventory().getContents()) {
|
||||
if (!item.isEmpty() && !EnchantmentHelper.hasVanishingCurse(item)) {
|
||||
- loot.add(CraftItemStack.asCraftMirror(item));
|
||||
+ loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - drop function taken from Inventory#dropAll (don't fire drop event)
|
||||
+ loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,20 +44,20 @@ index 3ca06c5dfed3bc2006bf2f42444353bfab14096d..be05a52be037042c6158100e2ce880b8
|
||||
@Override
|
||||
- public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) {
|
||||
- ItemEntity entityitem = super.drop(stack, throwRandomly, retainOwnership);
|
||||
+ public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean callDropEvent) { // Paper - override method with most params
|
||||
+ ItemEntity entityitem = super.drop(stack, throwRandomly, retainOwnership, callDropEvent); // Paper - override method with most params
|
||||
+ public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean callDropEvent) { // Paper - Restore vanilla drops behavior; override method with most params
|
||||
+ ItemEntity entityitem = super.drop(stack, throwRandomly, retainOwnership, callDropEvent); // Paper - Restore vanilla drops behavior; override method with most params
|
||||
|
||||
if (entityitem == null) {
|
||||
return null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index cc86993aa7bf95ed5ae861feedc7e1049f12e210..1be10c57e374ad4018c08d96cfb69397a2f541d3 100644
|
||||
index cc86993aa7bf95ed5ae861feedc7e1049f12e210..82c5868222d22a5c5dc508c516d67bdcfa56d84b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2701,6 +2701,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||
|
||||
@Nullable
|
||||
public ItemEntity spawnAtLocation(ItemStack stack, float yOffset) {
|
||||
+ // Paper start
|
||||
+ // Paper start - Restore vanilla drops behavior
|
||||
+ return this.spawnAtLocation(stack, yOffset, null);
|
||||
+ }
|
||||
+ public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, @Nullable java.util.function.Consumer<ItemStack> dropConsumer) {
|
||||
@ -75,7 +75,7 @@ index cc86993aa7bf95ed5ae861feedc7e1049f12e210..1be10c57e374ad4018c08d96cfb69397
|
||||
+ }
|
||||
+ @Nullable
|
||||
+ public ItemEntity spawnAtLocation(ItemStack stack, float yOffset, @Nullable java.util.function.Consumer<? super ItemEntity> delayedAddConsumer) {
|
||||
+ // Paper end
|
||||
+ // Paper end - Restore vanilla drops behavior
|
||||
if (stack.isEmpty()) {
|
||||
return null;
|
||||
} else if (this.level().isClientSide) {
|
||||
@ -84,14 +84,14 @@ index cc86993aa7bf95ed5ae861feedc7e1049f12e210..1be10c57e374ad4018c08d96cfb69397
|
||||
// CraftBukkit start - Capture drops for death event
|
||||
if (this instanceof net.minecraft.world.entity.LivingEntity && !((net.minecraft.world.entity.LivingEntity) this).forceDrops) {
|
||||
- ((net.minecraft.world.entity.LivingEntity) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack)); // Paper - mirror so we can destroy it later
|
||||
+ // Paper start
|
||||
+ // Paper start - Restore vanilla drops behavior
|
||||
+ ((net.minecraft.world.entity.LivingEntity) this).drops.add(new net.minecraft.world.entity.Entity.DefaultDrop(stack, itemStack -> {
|
||||
+ ItemEntity itemEntity = new ItemEntity(this.level, this.getX(), this.getY() + (double) yOffset, this.getZ(), itemStack); // stack is copied before consumer
|
||||
+ itemEntity.setDefaultPickUpDelay();
|
||||
+ this.level.addFreshEntity(itemEntity);
|
||||
+ if (delayedAddConsumer != null) delayedAddConsumer.accept(itemEntity);
|
||||
+ }));
|
||||
+ // Paper end
|
||||
+ // Paper end - Restore vanilla drops behavior
|
||||
return null;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@ -104,7 +104,7 @@ index cc86993aa7bf95ed5ae861feedc7e1049f12e210..1be10c57e374ad4018c08d96cfb69397
|
||||
return this.spawnAtLocation(entityitem);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index bc45bd5816b1b62cdd6011f2372702451b83f22b..96885946be3b8e129984353f3dfe4330e73ad84a 100644
|
||||
index bc45bd5816b1b62cdd6011f2372702451b83f22b..42feb50674cba50fb7c5883f679e111c5412fb9b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -254,7 +254,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@ -112,12 +112,12 @@ index bc45bd5816b1b62cdd6011f2372702451b83f22b..96885946be3b8e129984353f3dfe4330
|
||||
public int expToDrop;
|
||||
public boolean forceDrops;
|
||||
- public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ public ArrayList<DefaultDrop> drops = new ArrayList<>(); // Paper
|
||||
+ public ArrayList<DefaultDrop> drops = new ArrayList<>(); // Paper - Restore vanilla drops behavior
|
||||
public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
public boolean collides = true;
|
||||
public Set<UUID> collidableExemptions = new HashSet<>();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 71bcd55d9d71fbd5bf3014c7e36d1456d8d5c3fd..c59e44c45d9c8c719b34e85fb3b753ac3788842d 100644
|
||||
index 71bcd55d9d71fbd5bf3014c7e36d1456d8d5c3fd..68ecf0203e23cb6360d05bec18d9c1c413d84650 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -534,10 +534,10 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
@ -125,7 +125,7 @@ index 71bcd55d9d71fbd5bf3014c7e36d1456d8d5c3fd..c59e44c45d9c8c719b34e85fb3b753ac
|
||||
protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) {
|
||||
super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops);
|
||||
- ItemEntity entityitem = this.spawnAtLocation((ItemLike) Items.NETHER_STAR);
|
||||
+ ItemEntity entityitem = this.spawnAtLocation(new net.minecraft.world.item.ItemStack(Items.NETHER_STAR), 0, ItemEntity::setExtendedLifetime); // Paper - spawnAtLocation returns null so modify the item entity with a consumer
|
||||
+ ItemEntity entityitem = this.spawnAtLocation(new net.minecraft.world.item.ItemStack(Items.NETHER_STAR), 0, ItemEntity::setExtendedLifetime); // Paper - Restore vanilla drops behavior; spawnAtLocation returns null so modify the item entity with a consumer
|
||||
|
||||
if (entityitem != null) {
|
||||
- entityitem.setExtendedLifetime();
|
||||
@ -134,7 +134,7 @@ index 71bcd55d9d71fbd5bf3014c7e36d1456d8d5c3fd..c59e44c45d9c8c719b34e85fb3b753ac
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
index ab708b256183fc54fe8e13f341d8a38acf611739..1e86e86b0a100a5d14aee10b60e70c32d2733660 100644
|
||||
index ab708b256183fc54fe8e13f341d8a38acf611739..a9c1f99ba2461333bd154ac16e812031f234f7a6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
@@ -610,7 +610,7 @@ public class ArmorStand extends LivingEntity {
|
||||
@ -142,7 +142,7 @@ index ab708b256183fc54fe8e13f341d8a38acf611739..1e86e86b0a100a5d14aee10b60e70c32
|
||||
}
|
||||
|
||||
- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - spawn drops correctly
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior
|
||||
return this.brokenByAnything(damageSource); // Paper
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ index ab708b256183fc54fe8e13f341d8a38acf611739..1e86e86b0a100a5d14aee10b60e70c32
|
||||
itemstack = (ItemStack) this.handItems.get(i);
|
||||
if (!itemstack.isEmpty()) {
|
||||
- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe & spawn drops correctly
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly
|
||||
this.handItems.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
@ -160,12 +160,12 @@ index ab708b256183fc54fe8e13f341d8a38acf611739..1e86e86b0a100a5d14aee10b60e70c32
|
||||
itemstack = (ItemStack) this.armorItems.get(i);
|
||||
if (!itemstack.isEmpty()) {
|
||||
- this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe & spawn drops correctly
|
||||
+ this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly
|
||||
this.armorItems.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0fbc158de 100644
|
||||
index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..66a05f9a5d114c7f39c3a88b7835e2a45f7db16f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -939,17 +939,21 @@ public class CraftEventFactory {
|
||||
@ -173,11 +173,11 @@ index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0
|
||||
|
||||
public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim) {
|
||||
- return CraftEventFactory.callEntityDeathEvent(victim, new ArrayList<org.bukkit.inventory.ItemStack>(0));
|
||||
+ return CraftEventFactory.callEntityDeathEvent(victim, new ArrayList<>(0)); // Paper
|
||||
+ return CraftEventFactory.callEntityDeathEvent(victim, new ArrayList<>(0)); // Paper - Restore vanilla drops behavior
|
||||
}
|
||||
|
||||
- public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<org.bukkit.inventory.ItemStack> drops) {
|
||||
+ public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<Entity.DefaultDrop> drops) { // Paper
|
||||
+ public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<Entity.DefaultDrop> drops) { // Paper - Restore vanilla drops behavior
|
||||
// Paper start
|
||||
return CraftEventFactory.callEntityDeathEvent(victim, drops, com.google.common.util.concurrent.Runnables.doNothing());
|
||||
}
|
||||
@ -190,7 +190,7 @@ index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0
|
||||
// Paper end
|
||||
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
|
||||
- EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
|
||||
+ EntityDeathEvent event = new EntityDeathEvent(entity, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward()); // Paper
|
||||
+ EntityDeathEvent event = new EntityDeathEvent(entity, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward()); // Paper - Restore vanilla drops behavior
|
||||
populateFields(victim, event); // Paper - make cancellable
|
||||
CraftWorld world = (CraftWorld) entity.getWorld();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -199,15 +199,15 @@ index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0
|
||||
lootCheck.run(); // Paper - advancement triggers before destroying items
|
||||
|
||||
- for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||
+ // Paper start
|
||||
+ // Paper start - Restore vanilla drops behavior
|
||||
+ for (Entity.DefaultDrop drop : drops) {
|
||||
+ if (drop == null) continue;;
|
||||
+ final org.bukkit.inventory.ItemStack stack = drop.stack();
|
||||
+ // Paper end
|
||||
+ // Paper end - Restore vanilla drops behavior
|
||||
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;
|
||||
|
||||
- world.dropItem(entity.getLocation(), stack); // Paper - note: dropItem already clones due to this being bukkit -> NMS
|
||||
+ drop.runConsumer(world, entity.getLocation()); // Paper
|
||||
+ drop.runConsumer(world, entity.getLocation()); // Paper - Restore vanilla drops behavior
|
||||
if (stack instanceof CraftItemStack) stack.setAmount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe, but don't nuke bukkit stacks of manually added items
|
||||
}
|
||||
|
||||
@ -215,10 +215,10 @@ index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0
|
||||
}
|
||||
|
||||
- public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, List<org.bukkit.inventory.ItemStack> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure
|
||||
+ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, List<Entity.DefaultDrop> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure & improve drops
|
||||
+ public static PlayerDeathEvent callPlayerDeathEvent(ServerPlayer victim, List<Entity.DefaultDrop> drops, net.kyori.adventure.text.Component deathMessage, boolean keepInventory) { // Paper - Adventure & Restore vanilla drops behavior
|
||||
CraftPlayer entity = victim.getBukkitEntity();
|
||||
- PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
|
||||
+ PlayerDeathEvent event = new PlayerDeathEvent(entity, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(), 0, deathMessage); // Paper - improve drops
|
||||
+ PlayerDeathEvent event = new PlayerDeathEvent(entity, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(), 0, deathMessage); // Paper - Restore vanilla drops behavior
|
||||
event.setKeepInventory(keepInventory);
|
||||
event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel
|
||||
populateFields(victim, event); // Paper - make cancellable
|
||||
@ -227,15 +227,15 @@ index e15e60b67c17a0ea4fedb4882ea839e1b9b1ae60..7d9fc84dd684093098fdefdcaf7c92a0
|
||||
victim.newExp = event.getNewExp();
|
||||
|
||||
- for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||
+ // Paper start
|
||||
+ // Paper start - Restore vanilla drops behavior
|
||||
+ for (Entity.DefaultDrop drop : drops) {
|
||||
+ if (drop == null) continue;
|
||||
+ final org.bukkit.inventory.ItemStack stack = drop.stack();
|
||||
+ // Paper end
|
||||
+ // Paper end - Restore vanilla drops behavior
|
||||
if (stack == null || stack.getType() == Material.AIR) continue;
|
||||
|
||||
- world.dropItem(entity.getLocation(), stack);
|
||||
+ drop.runConsumer(world, entity.getLocation()); // Paper
|
||||
+ drop.runConsumer(world, entity.getLocation()); // Paper - Restore vanilla drops behavior
|
||||
}
|
||||
|
||||
return event;
|
||||
|
@ -8,7 +8,7 @@ In general, the client now has an acknowledgment system which will prevent block
|
||||
It should be noted that this system does not yet support block entities, so those still need to resynced when needed.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48cff36fa9 100644
|
||||
index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..51bf6c740ac08548eedf0c026c5a66d6a3c6d83e 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -199,7 +199,7 @@ public class ServerPlayerGameMode {
|
||||
@ -52,7 +52,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
|
||||
+ //} else if (data.getBlock() instanceof TrapDoorBlock) {
|
||||
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
+ //}
|
||||
+ // Paper end
|
||||
+ // Paper end - Don't resync blocks
|
||||
} else if (!iblockdata.isAir()) {
|
||||
iblockdata.attack(this.level, pos, this.player);
|
||||
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
|
||||
@ -87,7 +87,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
|
||||
if (isSwordNoBreak) {
|
||||
return false;
|
||||
}
|
||||
+ // Paper start - Dont resync blocks
|
||||
+ // Paper start - Don't resync blocks
|
||||
// Let the client know the block still exists
|
||||
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
+ //this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
@ -99,7 +99,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
|
||||
+ //for (Direction dir : Direction.values()) {
|
||||
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos.relative(dir)));
|
||||
+ //}
|
||||
+ // Paper end
|
||||
+ // Paper end - Don't resync blocks
|
||||
|
||||
// Update any tile entity data for this block
|
||||
if (!captureSentBlockEntities) { // Paper - Toggle this location for capturing as this is used for api
|
||||
@ -112,17 +112,17 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
|
||||
+ // Paper start - Don't resync blocks
|
||||
+ // boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
|
||||
+ // player.connection.send(new ClientboundBlockUpdatePacket(world, bottom ? blockposition.above() : blockposition.below()));
|
||||
+ // Paper end
|
||||
+ // Paper end - Don't resync blocks
|
||||
} else if (iblockdata.getBlock() instanceof CakeBlock) {
|
||||
player.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
||||
} else if (this.interactItemStack.getItem() instanceof DoubleHighBlockItem) {
|
||||
// send a correcting update to the client, as it already placed the upper half of the bisected item
|
||||
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above()));
|
||||
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - don't resync blocks
|
||||
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - Don't resync blocks
|
||||
|
||||
// send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
|
||||
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above()));
|
||||
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - don't resync blocks
|
||||
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - Don't resync blocks
|
||||
// Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method
|
||||
} else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) {
|
||||
player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId));
|
||||
@ -149,7 +149,7 @@ index 277555a26e8281dd1a626e572794b08cf51d00c5..aa0f09a18ea781e027ea70928b30d3e9
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 666533627e772e5e85ba04e65dd2b376efc0b139..5b8a1f31e0b55da15daa4ab271317e4393a87e96 100644
|
||||
index 666533627e772e5e85ba04e65dd2b376efc0b139..bab97eedd92f7131fd0cd478580ddd52d2173de9 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -457,10 +457,12 @@ public final class ItemStack {
|
||||
@ -160,12 +160,12 @@ index 666533627e772e5e85ba04e65dd2b376efc0b139..5b8a1f31e0b55da15daa4ab271317e43
|
||||
- for (Direction dir : Direction.values()) {
|
||||
- ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
|
||||
- }
|
||||
+ // Paper start - don't resync blocks
|
||||
+ // Paper start - Don't resync blocks
|
||||
+ // BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
||||
+ // for (Direction dir : Direction.values()) {
|
||||
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
|
||||
+ // }
|
||||
+ // Paper end
|
||||
+ // Paper end - Don't resync blocks
|
||||
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
|
||||
} else {
|
||||
// Change the stack to its new contents if it hasn't been tampered with.
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add experience points API
|
||||
|
||||
|
||||
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 7f3466340891b4409d1399ebeb2ca865d77841cd..3e597833b57377b855505b8a0f2744801c791f90 100644
|
||||
index 7f3466340891b4409d1399ebeb2ca865d77841cd..0a9ee8aee52b34566f1613229951e33e53394f29 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1833,7 +1833,7 @@ public abstract class Player extends LivingEntity {
|
||||
@ -13,7 +13,7 @@ index 7f3466340891b4409d1399ebeb2ca865d77841cd..3e597833b57377b855505b8a0f274480
|
||||
|
||||
public int getXpNeededForNextLevel() {
|
||||
- return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
|
||||
+ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); // Paper - diff on change
|
||||
+ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); // Paper - diff on change; calculateTotalExperiencePoints
|
||||
}
|
||||
// Paper start - send SoundEffect to everyone who can see fromEntity
|
||||
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Add drops to shear events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
|
||||
index 45d356c1ed888b4d749379ceaa8a95d7d7c876d5..887e75c940ab5089f4e42e4553ab95adf172df46 100644
|
||||
index 45d356c1ed888b4d749379ceaa8a95d7d7c876d5..8d65cdb013706a932c2c73231108b2810b99e1c7 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
|
||||
@@ -103,11 +103,14 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior {
|
||||
@ -13,38 +13,38 @@ index 45d356c1ed888b4d749379ceaa8a95d7d7c876d5..887e75c940ab5089f4e42e4553ab95ad
|
||||
if (ishearable.readyForShearing()) {
|
||||
// CraftBukkit start
|
||||
- if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) {
|
||||
+ // Paper start
|
||||
+ // Paper start - Add drops to shear events
|
||||
+ org.bukkit.event.block.BlockShearEntityEvent event = CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem, ishearable.generateDefaultDrops());
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Paper end
|
||||
+ // Paper end - Add drops to shear events
|
||||
continue;
|
||||
}
|
||||
// CraftBukkit end
|
||||
- ishearable.shear(SoundSource.BLOCKS);
|
||||
+ ishearable.shear(SoundSource.BLOCKS, CraftItemStack.asNMSCopy(event.getDrops())); // Paper
|
||||
+ ishearable.shear(SoundSource.BLOCKS, CraftItemStack.asNMSCopy(event.getDrops())); // Paper - Add drops to shear events
|
||||
worldserver.gameEvent((Entity) null, GameEvent.SHEAR, blockposition);
|
||||
return true;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Shearable.java b/src/main/java/net/minecraft/world/entity/Shearable.java
|
||||
index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..4921d1b2ff9112374477c5c9b4a68cc75a51dbf8 100644
|
||||
index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..2ee48ac3b665db2b02bcb1a30ec972d43a3725b0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Shearable.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Shearable.java
|
||||
@@ -3,7 +3,13 @@ package net.minecraft.world.entity;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
|
||||
public interface Shearable {
|
||||
+ default void shear(SoundSource soundCategory, java.util.List<net.minecraft.world.item.ItemStack> drops) { this.shear(soundCategory); } // Paper
|
||||
+ default void shear(SoundSource soundCategory, java.util.List<net.minecraft.world.item.ItemStack> drops) { this.shear(soundCategory); } // Paper - Add drops to shear events
|
||||
void shear(SoundSource shearedSoundCategory);
|
||||
|
||||
boolean readyForShearing();
|
||||
+ // Paper start - ensure all implementing entities override this
|
||||
+ // Paper start - custom shear drops; ensure all implementing entities override this
|
||||
+ default java.util.List<net.minecraft.world.item.ItemStack> generateDefaultDrops() {
|
||||
+ return java.util.Collections.emptyList();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - custom shear drops
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||
index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf1993da9d839 100644
|
||||
index e42b0b19019ef74733fd19b08f882cccff920142..7a82ba6e29fde33841c049e8520300aa66608f34 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
|
||||
@@ -122,11 +122,18 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
|
||||
@ -65,7 +65,7 @@ index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf199
|
||||
+ // Paper end - custom shear drops
|
||||
// CraftBukkit end
|
||||
- this.shear(SoundSource.PLAYERS);
|
||||
+ this.shear(SoundSource.PLAYERS, drops); // Paper
|
||||
+ this.shear(SoundSource.PLAYERS, drops); // Paper - custom shear drops
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
if (!this.level().isClientSide) {
|
||||
itemstack.hurtAndBreak(1, player, (entityhuman1) -> {
|
||||
@ -106,7 +106,7 @@ index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf199
|
||||
- }
|
||||
- this.level().addFreshEntity(entityitem);
|
||||
- // CraftBukkit end
|
||||
+ // Paper start - custom shear drops (moved drop generation to separate method)
|
||||
+ // Paper start - custom shear drops; moved drop generation to separate method
|
||||
+ for (final ItemStack drop : drops) {
|
||||
+ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), drop);
|
||||
+ this.spawnAtLocation(entityitem);
|
||||
@ -233,7 +233,7 @@ index 8adcfc8f6772a32b5915e4a07100e8eb735f907a..b5d6857eaf2bed14adcb5f5e80d91b44
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 7d9fc84dd684093098fdefdcaf7c92a0fbc158de..2aab68bac670dcd134d817940020214c7b0797f9 100644
|
||||
index 66a05f9a5d114c7f39c3a88b7835e2a45f7db16f..cbaaa7d54e70bf4e0604d1716d253453bab03744 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1718,20 +1718,20 @@ public class CraftEventFactory {
|
||||
|
@ -16,7 +16,7 @@ sideeffects, meaning the disable event cannot share a handlerlist with
|
||||
the cooldown event
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 5af48151159135b869ec4753bbcf79dd257c1570..e0cf7771488ab0065708d68b4e8550b865af0ed4 100644
|
||||
index 5af48151159135b869ec4753bbcf79dd257c1570..538eaf327bdae975ce854871189990fbfe17b918 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1703,7 +1703,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
@ -24,16 +24,16 @@ index 5af48151159135b869ec4753bbcf79dd257c1570..e0cf7771488ab0065708d68b4e8550b8
|
||||
|
||||
if (this.random.nextFloat() < f) {
|
||||
- player.getCooldowns().addCooldown(Items.SHIELD, 100);
|
||||
+ // Paper start
|
||||
+ // Paper start - Add PlayerShieldDisableEvent
|
||||
+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitEntity(), 100);
|
||||
+ if (!shieldDisableEvent.callEvent()) return;
|
||||
+ player.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown());
|
||||
+ // Paper end
|
||||
+ // Paper end - Add PlayerShieldDisableEvent
|
||||
this.level().broadcastEntityEvent(player, (byte) 30);
|
||||
}
|
||||
}
|
||||
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 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f5390843e 100644
|
||||
index 0a9ee8aee52b34566f1613229951e33e53394f29..5fffd5fde567affa51b3cf4bcc58249134a95e20 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -979,7 +979,7 @@ public abstract class Player extends LivingEntity {
|
||||
@ -41,7 +41,7 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f
|
||||
super.blockUsingShield(attacker);
|
||||
if (attacker.canDisableShield()) {
|
||||
- this.disableShield(true);
|
||||
+ this.disableShield(true, attacker); // Paper
|
||||
+ this.disableShield(true, attacker); // Paper - Add PlayerShieldDisableEvent
|
||||
}
|
||||
|
||||
}
|
||||
@ -49,14 +49,14 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f
|
||||
this.attack(target);
|
||||
}
|
||||
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Paper - add player shield disable event
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Paper - Add PlayerShieldDisableEvent
|
||||
public void disableShield(boolean sprinting) {
|
||||
+ // Paper start - add player shield disable event
|
||||
+ // Paper start - Add PlayerShieldDisableEvent
|
||||
+ disableShield(sprinting, null);
|
||||
+ }
|
||||
+
|
||||
+ public void disableShield(boolean sprinting, @Nullable LivingEntity attacker) {
|
||||
+ // Paper end - add player shield disable event
|
||||
+ // Paper end - Add PlayerShieldDisableEvent
|
||||
float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;
|
||||
|
||||
if (sprinting) {
|
||||
@ -65,7 +65,7 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f
|
||||
|
||||
if (this.random.nextFloat() < f) {
|
||||
- this.getCooldowns().addCooldown(Items.SHIELD, 100);
|
||||
+ // Paper start - add player shield disable event
|
||||
+ // Paper start - Add PlayerShieldDisableEvent
|
||||
+ final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null;
|
||||
+ if (finalAttacker != null) {
|
||||
+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100);
|
||||
@ -74,7 +74,7 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f
|
||||
+ } else {
|
||||
+ this.getCooldowns().addCooldown(Items.SHIELD, 100);
|
||||
+ }
|
||||
+ // Paper end - add player shield disable event
|
||||
+ // Paper end - Add PlayerShieldDisableEvent
|
||||
this.stopUsingItem();
|
||||
this.level().broadcastEntityEvent(this, (byte) 30);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ in order to fire the BlockDispenseEvent. This patch corrects
|
||||
that.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
index f42a86549e389ec53962f7a5e7a625f351cd4724..bf1c5834717758991c1520afd4b2a5c3fa68a558 100644
|
||||
index f42a86549e389ec53962f7a5e7a625f351cd4724..a1739f6f091fe922ac0e97141fc9446664713fc3 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
@@ -628,7 +628,13 @@ public interface DispenseItemBehavior {
|
||||
@ -19,7 +19,7 @@ index f42a86549e389ec53962f7a5e7a625f351cd4724..bf1c5834717758991c1520afd4b2a5c3
|
||||
+ // Paper start - correctly check if the bucket place will succeed
|
||||
+ /* Taken from SolidBucketItem#emptyContents */
|
||||
+ boolean willEmptyContentsSolidBucketItem = dispensiblecontaineritem instanceof net.minecraft.world.item.SolidBucketItem && worldserver.isInWorldBounds(blockposition) && iblockdata.isAir();
|
||||
+ /* Take from BucketItem#emptyContents */
|
||||
+ /* Taken from BucketItem#emptyContents */
|
||||
+ boolean willEmptyBucketItem = dispensiblecontaineritem instanceof final BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (iblockdata.isAir() || iblockdata.canBeReplaced(bucketItem.content) || (iblockdata.getBlock() instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, worldserver, blockposition, iblockdata, bucketItem.content)));
|
||||
+ if (willEmptyContentsSolidBucketItem || willEmptyBucketItem) {
|
||||
+ // Paper end - correctly check if the bucket place will succeed
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Validate ResourceLocation in NBT reading
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index 18fad4f083862ace2bc56579883f548f6d697091..80083fed4b44b9d433925f09db83e559582109a1 100644
|
||||
index 18fad4f083862ace2bc56579883f548f6d697091..8e68a094a22243f3e84110ddf81136219ac1de7c 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -230,8 +230,10 @@ public final class NbtUtils {
|
||||
@ -17,7 +17,7 @@ index 18fad4f083862ace2bc56579883f548f6d697091..80083fed4b44b9d433925f09db83e559
|
||||
+ // Paper start - Validate resource location
|
||||
+ ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name"));
|
||||
+ Optional<? extends Holder<Block>> optional = resourceLocation != null ? blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation)) : Optional.empty();
|
||||
+ // Paper end
|
||||
+ // Paper end - Validate resource location
|
||||
if (optional.isEmpty()) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
} else {
|
||||
@ -53,7 +53,7 @@ index 00389d7ec3e8b059d5591a2019ba240fda2901fe..6cfce9755dd464a7afb01f9032e567ce
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index e0cf7771488ab0065708d68b4e8550b865af0ed4..a7fbd329ea6d36a46c00b4476c74e426dbbfe238 100644
|
||||
index 538eaf327bdae975ce854871189990fbfe17b918..a31e8bb38b29a7c30cecb762d3ffec700e2186b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -620,7 +620,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
|
@ -7,7 +7,7 @@ This causes spawnAfterBreak to spawn xp by default, removing the need to manuall
|
||||
For classes that use custom xp amounts, they can drop the resources with disabling
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index a7d40d41a332f0612a2f1ff60c7082e4a8825ba1..6403341f2e9d7ac4251336cb0bcc5d79dbb7bb0e 100644
|
||||
index a7d40d41a332f0612a2f1ff60c7082e4a8825ba1..e0b70ae59ed7ea0543c8cb87b0e7e5f0bc9385b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1103,7 +1103,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@ -15,46 +15,46 @@ index a7d40d41a332f0612a2f1ff60c7082e4a8825ba1..6403341f2e9d7ac4251336cb0bcc5d79
|
||||
BlockEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(pos) : null;
|
||||
|
||||
- Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY);
|
||||
+ Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY, false); // Don't drop xp
|
||||
+ iblockdata.getBlock().popExperience((ServerLevel) this, pos, xp, breakingEntity); // Paper - handle drop experience logic, custom amount
|
||||
+ Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping
|
||||
+ iblockdata.getBlock().popExperience((ServerLevel) this, pos, xp, breakingEntity); // Paper - Properly handle xp dropping; custom amount
|
||||
}
|
||||
|
||||
boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index c450caed1a8d14f3bd56d0336a9bf72a5adca14f..e21867d3956078bb0db4ceed45e5811e9acd7377 100644
|
||||
index c450caed1a8d14f3bd56d0336a9bf72a5adca14f..a4b51821d8bcf9fdb7ff5e200c33ac2c565eece1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -333,23 +333,31 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) {
|
||||
items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop));
|
||||
}
|
||||
+ Block block = state.getBlock();
|
||||
+ Block block = state.getBlock(); // Paper - Properly handle xp dropping
|
||||
io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items);
|
||||
+ event.setExpToDrop(block.getExpDrop(state, (ServerLevel) world, pos, net.minecraft.world.item.ItemStack.EMPTY, true));
|
||||
+ event.setExpToDrop(block.getExpDrop(state, (ServerLevel) world, pos, net.minecraft.world.item.ItemStack.EMPTY, true)); // Paper - Properly handle xp dropping
|
||||
event.callEvent();
|
||||
for (var drop : event.getDrops()) {
|
||||
popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop));
|
||||
}
|
||||
- state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true);
|
||||
+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, false);
|
||||
+ block.popExperience((ServerLevel) world, pos, event.getExpToDrop());
|
||||
+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, false); // Paper - Properly handle xp dropping
|
||||
+ block.popExperience((ServerLevel) world, pos, event.getExpToDrop()); // Paper - Properly handle xp dropping
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) {
|
||||
+ // Paper start
|
||||
+ // Paper start - Properly handle xp dropping
|
||||
+ dropResources(state, world, pos, blockEntity, entity, tool, true);
|
||||
+ }
|
||||
+ public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool, boolean dropExperience) {
|
||||
+ // Paper end
|
||||
+ // Paper end - Properly handle xp dropping
|
||||
if (world instanceof ServerLevel) {
|
||||
Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, tool).forEach((itemstack1) -> {
|
||||
Block.popResource(world, pos, itemstack1);
|
||||
});
|
||||
- state.spawnAfterBreak((ServerLevel) world, pos, tool, true);
|
||||
+ state.spawnAfterBreak((ServerLevel) world, pos, tool, dropExperience); // Paper
|
||||
+ state.spawnAfterBreak((ServerLevel) world, pos, tool, dropExperience); // Paper - Properly handle xp dropping
|
||||
}
|
||||
|
||||
}
|
||||
@ -63,24 +63,24 @@ index c450caed1a8d14f3bd56d0336a9bf72a5adca14f..e21867d3956078bb0db4ceed45e5811e
|
||||
player.causeFoodExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); // CraftBukkit - EntityExhaustionEvent
|
||||
if (includeDrops) { // Paper
|
||||
- Block.dropResources(state, world, pos, blockEntity, player, tool);
|
||||
+ Block.dropResources(state, world, pos, blockEntity, player, tool, dropExp); // Paper
|
||||
+ Block.dropResources(state, world, pos, blockEntity, player, tool, dropExp); // Paper - Properly handle xp dropping
|
||||
} // Paper
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index 3ab8b99837b1d1faea722c598b0228b2780be8b1..401f1b418a4f57059e991cc958ebadb31239a581 100644
|
||||
index 17d2b90441d7513d7907b988610be8604ac05282..f03fd4bc44fb95cc17cae69dbe3fd684ed562d6f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -1286,6 +1286,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
|
||||
public void spawnAfterBreak(ServerLevel world, BlockPos pos, ItemStack tool, boolean dropExperience) {
|
||||
this.getBlock().spawnAfterBreak(this.asState(), world, pos, tool, dropExperience);
|
||||
+ if (dropExperience) {getBlock().popExperience(world, pos, this.getBlock().getExpDrop(asState(), world, pos, tool, true));} // Paper - spawn experience
|
||||
+ if (dropExperience) {getBlock().popExperience(world, pos, this.getBlock().getExpDrop(asState(), world, pos, tool, true));} // Paper - Properly handle xp dropping
|
||||
}
|
||||
|
||||
public List<ItemStack> getDrops(LootParams.Builder builder) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index e5506a7d074a9f89d41f4d5d7549a458779bef20..520b53bc604e6755251f0b14e91dce56bc5501ce 100644
|
||||
index e5506a7d074a9f89d41f4d5d7549a458779bef20..4b42ef2a876ea210d948238e63fd7a2b7035bb5b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -503,7 +503,7 @@ public class CraftBlock implements Block {
|
||||
@ -88,7 +88,7 @@ index e5506a7d074a9f89d41f4d5d7549a458779bef20..520b53bc604e6755251f0b14e91dce56
|
||||
// Modelled off EntityHuman#hasBlock
|
||||
if (block != Blocks.AIR && (item == null || !iblockdata.requiresCorrectToolForDrops() || nmsItem.isCorrectToolForDrops(iblockdata))) {
|
||||
- net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem);
|
||||
+ net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem, false); // Paper
|
||||
+ net.minecraft.world.level.block.Block.dropResources(iblockdata, this.world.getMinecraftWorld(), this.position, this.world.getBlockEntity(this.position), null, nmsItem, false); // Paper - Properly handle xp dropping
|
||||
// Paper start - improve Block#breanNaturally
|
||||
if (triggerEffect) {
|
||||
if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren