mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
de04cbced5
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
95 lines
5 KiB
Diff
95 lines
5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Thu, 2 Jan 2020 12:25:07 -0600
|
|
Subject: [PATCH] Improve Block#breakNaturally API
|
|
|
|
Adds bool parameter to play world effect on block break
|
|
|
|
Adds bool parameter to drop xp from blocks
|
|
|
|
Fixes fluid-logged blocks not leaving fluid behind if
|
|
broken
|
|
|
|
Handles special cases for ice and turtle eggs
|
|
|
|
== AT ==
|
|
public net.minecraft.world.level.block.TurtleEggBlock decreaseEggs(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V
|
|
|
|
Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/IceBlock.java b/src/main/java/net/minecraft/world/level/block/IceBlock.java
|
|
index c919b5a382b1bfcafd938ff926d9146cc5cf0cdc..f05998e0af1e844f19bf86b74f652a9901088c37 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/IceBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/IceBlock.java
|
|
@@ -35,6 +35,11 @@ public class IceBlock extends HalfTransparentBlock {
|
|
@Override
|
|
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) {
|
|
super.playerDestroy(world, player, pos, state, blockEntity, tool);
|
|
+ // Paper start
|
|
+ this.afterDestroy(world, pos, tool);
|
|
+ }
|
|
+ public void afterDestroy(Level world, BlockPos pos, ItemStack tool) {
|
|
+ // Paper end
|
|
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) {
|
|
if (world.dimensionType().ultraWarm()) {
|
|
world.removeBlock(pos, false);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index 7f2e4fd1d81d6439475f30e62f0348f38bbc985d..d0b1a419c9bc73066d79459dc3e5998160f8038b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -452,6 +452,18 @@ public class CraftBlock implements Block {
|
|
|
|
@Override
|
|
public boolean breakNaturally(ItemStack item) {
|
|
+ // Paper start
|
|
+ return this.breakNaturally(item, false);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean breakNaturally(boolean triggerEffect, boolean dropExperience) {
|
|
+ return this.breakNaturally(null, triggerEffect, dropExperience);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean breakNaturally(ItemStack item, boolean triggerEffect, boolean dropExperience) {
|
|
+ // Paper end
|
|
// Order matters here, need to drop before setting to air so skulls can get their data
|
|
net.minecraft.world.level.block.state.BlockState iblockdata = this.getNMS();
|
|
net.minecraft.world.level.block.Block block = iblockdata.getBlock();
|
|
@@ -461,11 +473,35 @@ public class CraftBlock implements Block {
|
|
// 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);
|
|
+ // Paper start - improve Block#breanNaturally
|
|
+ if (triggerEffect) {
|
|
+ if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.BaseFireBlock) {
|
|
+ this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.SOUND_EXTINGUISH_FIRE, this.position, 0);
|
|
+ } else {
|
|
+ this.world.levelEvent(net.minecraft.world.level.block.LevelEvent.PARTICLES_DESTROY_BLOCK, this.position, net.minecraft.world.level.block.Block.getId(iblockdata));
|
|
+ }
|
|
+ }
|
|
+ if (dropExperience) block.popExperience(this.world.getMinecraftWorld(), this.position, block.getExpDrop(iblockdata, this.world.getMinecraftWorld(), this.position, nmsItem, true));
|
|
+ // Paper end
|
|
result = true;
|
|
}
|
|
|
|
// SPIGOT-6778: Directly call setBlock instead of setTypeAndData, so that the tile entiy is not removed and custom remove logic is run.
|
|
- return this.world.setBlock(this.position, Blocks.AIR.defaultBlockState(), 3) && result;
|
|
+ // Paper start - improve breakNaturally
|
|
+ boolean destroyed = this.world.removeBlock(this.position, false);
|
|
+ if (destroyed) {
|
|
+ block.destroy(this.world, this.position, iblockdata);
|
|
+ }
|
|
+ if (result) {
|
|
+ // special cases
|
|
+ if (block instanceof net.minecraft.world.level.block.IceBlock iceBlock) {
|
|
+ iceBlock.afterDestroy(this.world.getMinecraftWorld(), this.position, nmsItem);
|
|
+ } else if (block instanceof net.minecraft.world.level.block.TurtleEggBlock turtleEggBlock) {
|
|
+ turtleEggBlock.decreaseEggs(this.world.getMinecraftWorld(), this.position, iblockdata);
|
|
+ }
|
|
+ }
|
|
+ return destroyed && result;
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|