Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@bd496d0 [ci skip] shuffle patches and rebuild PaperMC/Paper@79f2aa3 Update Velocity natives (#8387) PaperMC/Paper@21661a7 Fix jigsaw block kicking user (#8404) PaperMC/Paper@017af78 [ci skip] Added the missing "d" character (#8267) PaperMC/Paper@8a7dd61 Mark parsed PoiChunks with data as not loaded (#8405) PaperMC/Paper@7d3a882 Do not log throwable for duplicate entity adds PaperMC/Paper@8d69cfc Reduce allocation rate for checkBlock PaperMC/Paper@c6d7375 use BlockFormEvent for mud converting into clay (#8398) PaperMC/Paper@14c32bc Fix wrong yaw and pitch of CommandSourceStack#getBukkitLocation (#8411) PaperMC/Paper@f5fa691 Don't print full packages in new chunk system classes PaperMC/Paper@2534e5c Fix other jigsaw related disconnect bug (#8414) PaperMC/Paper@e9618f8 Add system property to dump stack on bad plugin class access (#8417) PaperMC/Paper@6d14093 Add getDrops to BlockState and isPreferredTool to BlockData (#8284) PaperMC/Paper@ec76e36 Fix a handful of vanilla bugs (#8187) PaperMC/Paper@ec3cfa9 Only create paper.yml-README.txt on config conversion (#8334) PaperMC/Paper@928bcc8 Updated Upstream (Bukkit/CraftBukkit) (#8430) PaperMC/Paper@616db71 Fix nothing mlg (#8432) PaperMC/Paper@011caa4 [ci skip] Minor patch cleanup PaperMC/Paper@15e1748 Avoid resizing of ArrayList in ChunkMap#getPlayers (#8416) PaperMC/Paper@ad3d357 Remove unnecessary onTrackingStart during nav warning PaperMC/Paper@9d63b07 Fix custom piglin interest items (#8097) PaperMC/Paper@ff67f1f EntityPickupItemEvent fixes (#8096) PaperMC/Paper@bcb4220 Correctly handle interactions with items on cooldown (#8008) PaperMC/Paper@60c973e Exempt players in creative/spectator from nether ceiling damage (#8427) PaperMC/Paper@77a50b9 Add Unmodifiable annotations to getDrops methods (#8440) PaperMC/Paper@c389b1c Fix configs that relied on outdated min/max y levels (#6986) PaperMC/Paper@57555b8 Add missing structure set seed configs (#8030) PaperMC/Paper@b097a24 Expose isUnderWater to Entity (#8454) PaperMC/Paper@6b26cfc Add missing Entity + Projectile API (#7632) PaperMC/Paper@de2d2d4 Add PlayerInventorySlotChangeEvent (#7321) PaperMC/Paper@f7c8d79 Fix stacktrace in server tests PaperMC/Paper@b9cf1ac Fix a classloading issue in tests (#8459) PaperMC/Paper@7fe34e9 Make CraftMinecartTNT public PaperMC/Paper@514a606 Elder Guardian appearance API (#8455) PaperMC/Paper@2094011 Update settings directory path in exceptions (#7968) PaperMC/Paper@0bdf997 Avoid cycle deprecation (#8466) PaperMC/Paper@eb68bd4 Allow changing bed's 'occupied' property (#8458) PaperMC/Paper@b560034 Avoid usages of RecipeChoice#getItemStack() (#8453) PaperMC/Paper@603df98 FIx bedrock patterns (#8474) PaperMC/Paper@ec00f99 Fix package for PlayerInventorySlotChangeEvent (#8475) PaperMC/Paper@236a296 Add LivingEntity#swingHand(EquipmentSlot) convenience method (#8456) PaperMC/Paper@7d64d7c Add converted Slot number to PlayerInventorySlotChangeEvent (#8482) PaperMC/Paper@ed2c88b Add LivingEntity knockback API (#8479) PaperMC/Paper@e1d4b26 Fix another case of missing chat headers PaperMC/Paper@f7da209 Fix inconsistent isChunkLoaded calls PaperMC/Paper@3dcfec4 Add stacktrace deobfuscation in more places (#8484) PaperMC/Paper@eb49418 [ci skip] Update workflow dependencies (#8489) PaperMC/Paper@a163a96 Load Allay duplication cooldown as a long (#8410) PaperMC/Paper@7187cab Detect headless JREs (#8491) PaperMC/Paper@60da35e fixed entity vehicle collision event not called (#5053) PaperMC/Paper@5cdb5f9 Optimized dirt and snow spreading (#5124) PaperMC/Paper@3d50709 Add MaterialTags for the different Types of Tools (#8049) PaperMC/Paper@6ea5aa3 Added EntityToggleSitEvent (#7579) PaperMC/Paper@58483c1 Add fire-tick-delay option (#8037) PaperMC/Paper@4e67c73 Add config setting for grindstone overstacking (#8156) PaperMC/Paper@d713b47 Add EquipmentSlot convenience methods (#8477) PaperMC/Paper@6665076 Add Moving Piston API (#7019) PaperMC/Paper@0b8f40c Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495) PaperMC/Paper@05bd9d6 Ignore impossible spawn tick (#8493) PaperMC/Paper@b8131a0 Mark chunks as saved after saving them PaperMC/Paper@44ce9b3 Updated Upstream (Bukkit/Spigot) (#8445) PaperMC/Paper@1c1aeb2 Only limit global sounds to same world if limiting radius (#8499) PaperMC/Paper@519cb4b Move classes added to net.minecraft.server to paper packages (#8500) PaperMC/Paper@fc5ae5b Fix incorrect handling of mustNotSave PaperMC/Paper@25cd3ee Add dirty flag to chunk tick lists PaperMC/Paper@7b3b593 [ci skip] Update checkout action in workflow (#8510) PaperMC/Paper@36869cc Fix new block data in EntityChangeBlockEvent for silverfish when mobGriefing isn't enabled (#8099) PaperMC/Paper@2432233 Add allow server listing & text filtering client options (#7595) PaperMC/Paper@954e6f0 Fix a bunch more forceDrops for dropping items (#8095) PaperMC/Paper@32d95e9 Track projectile source for fireworks from dispensers (#8044) PaperMC/Paper@0249750 Fix EntityArgument suggestion permissions to align with EntitySelector#checkPermissions (#8511) PaperMC/Paper@8acb05d Make CommandSyntaxException implement ComponentMessageThrowable (#8513) PaperMC/Paper@c264018 [ci skip] Undo modification to removed patches in latest commit (#8512) PaperMC/Paper@304ab35 [ci skip] Remove old todo file PaperMC/Paper@8a4b752 Fix wrong descriptor in ASMEventExecutorGenerator (#8506) PaperMC/Paper@b743144 Fix MC-147659 (#8423) PaperMC/Paper@aaf5e39 Deprecate unused VehicleEntityCollisionEvent methods (#8498) PaperMC/Paper@13cf546 Fix pumpkin growth modifier (#8517) PaperMC/Paper@b3b04f2 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#8515) PaperMC/Paper@93b2246 Fix EntityCombustEvent cancellation issues (#8529) PaperMC/Paper@4a9c9b3 Build updates PaperMC/Paper@e30b082 Fix setting difficulity inside of API (Fixes #8533) PaperMC/Paper@ebc0f6b Call PlayerLaunchProjectileEvent for trident (#8027) PaperMC/Paper@ab1c072 Remove old redundant fix (#8530) PaperMC/Paper@8ee344f [ci-skip] Rename Paper stop tp Paper end. (#8539) PaperMC/Paper@3d15120 Fix Advancement#getDisplay() api break (#8541) PaperMC/Paper@2b47227 Update Commodore modifications (#8542) PaperMC/Paper@df5fb94 Properly resend entities (#7041) PaperMC/Paper@3e9f39f Prevent compass from loading chunks PaperMC/Paper@3ac1a8d Cleanup misc import from last commit PaperMC/Paper@e6ee4cd Updated Upstream (CraftBukkit) (#8548) PaperMC/Paper@117579c Add PrePlayerAttackEntityEvent (#8369) PaperMC/Paper@112fa18 Show exception when headless JRE detection is triggered (#8559) PaperMC/Paper@5f4952f Cleanup reputation API + back with an EnumMap instead of array (#8258) PaperMC/Paper@564356d ensure reset EnderDragon boss event name (#8562) PaperMC/Paper@7955bcc fix MC-252817 (green map markers do not dissappear) (#8545) PaperMC/Paper@e22dacf update yarn param mappings (#8563) PaperMC/Paper@2151112 Fix/improve Affects Spawning API (#7329) PaperMC/Paper@84b5d4a Reorder bukkit damage source entity for explosion (#8553) PaperMC/Paper@b4c1ae6 Fix MC-121048 (#8429) PaperMC/Paper@825cb43 [ci skip] Add .fleet/ folder to .gitignore (#8574) PaperMC/Paper@669fed4 Fix MC-179072 (#8421) PaperMC/Paper@8f498dc Sync chunk load command improvements (#8554) PaperMC/Paper@3299886 [ci skip] Add TheFruxz to the license MIT list (#8575) PaperMC/Paper@0a6f100 Add more collision code skipping logic (#7581) PaperMC/Paper@76503f8 Strip coordinates from lodestone compasses (#8561) PaperMC/Paper@b95d4b2 Moving ATs from the at file to individual patches (#8573) PaperMC/Paper@4a3ae59 [ci skip] Add check for git repo (#8578) PaperMC/Paper@a7df847 Add Player Warden Warning API (#8470) PaperMC/Paper@3ab194e Avoid a cubed max search distance for POIs (#8576) PaperMC/Paper@55a16d8 Fix Varint21FrameDecoder cached length buf usage PaperMC/Paper@e6e37ba Add api to resolve components (#7648) PaperMC/Paper@7168438 [ci skip] Rework workflows to support optional paperclip build (#8583) PaperMC/Paper@da230d5 More vanilla friendly methods to update trades (#8478) PaperMC/Paper@8aff07a Add /paper dumplisteners command (#8507) PaperMC/Paper@b8919a7 pr command action fixes (#8591) PaperMC/Paper@185fa48 Fix chest relooting mechanics (#8580) PaperMC/Paper@b4beac0 Fixes potential issues arising from optimizing getPlayerByUUID (#8585) PaperMC/Paper@f637b1a Fix async entity add due to fungus trees (#7626) PaperMC/Paper@414ea80 ItemStack damage API (#7801) PaperMC/Paper@d98c370 Add displayName methods for advancements (#8584) PaperMC/Paper@44bb599 Add Tick TemporalUnit (#5445) PaperMC/Paper@9f7eef8 Friction API (#6611) PaperMC/Paper@4048d3e Allow using degrees for ArmorStand rotations (#7847) PaperMC/Paper@f59c802 Schoolable Fish API (#7089) PaperMC/Paper@21b964a Added ability to control player's insomnia and phantoms spawning (#6500) PaperMC/Paper@f1583fc Add `/paper dumplisteners tofile` and increase detail of command output (#8592) PaperMC/Paper@28b4027 Fix packet duplicating at some points (#8566) PaperMC/Paper@309133e Fix preemptive connection dropping during shutdown process (#8546) PaperMC/Paper@8796175 Handle legacy quirk in the console formatter (#8434) PaperMC/Paper@54daefa Fix whitespace error in recent patch PaperMC/Paper@41ab602 [ci skip] couple more fixes for build pr jar label (#8599) PaperMC/Paper@c40f8d5 Sync offhand slot in menus (#7341) PaperMC/Paper@425baed Fully deserialise persistent anger post async load (#8560) PaperMC/Paper@ec6a9a3 Updated Upstream (Bukkit/CraftBukkit) (#8604) PaperMC/Paper@96fdafd Player Entity Tracking Events (#4722) PaperMC/Paper@407a445 Fix dumplisteners missing folder creation PaperMC/Paper@b07d5e0 Limit pet look distance (#8612) PaperMC/Paper@476ef25 Add missing Fluid type (#8608)
74 lines
4.7 KiB
Diff
74 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: lexikiq <noellekiq@gmail.com>
|
|
Date: Thu, 1 Jul 2021 21:36:03 -0400
|
|
Subject: [PATCH] Add BlockDropResourcesEvent
|
|
|
|
Adds an event which allows plugin developers
|
|
to easily get the items being dropped by any
|
|
block instead of only blocks broken by players.
|
|
|
|
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 2e65b44f10aeb44fd524a58e7eb815a566c1ad61..cdeecf0032db60385db19d6a6607da792f532a79 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -308,7 +308,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
ServerLevel worldserver = lootContext.getLevel();
|
|
BlockPos blockposition = new BlockPos((Vec3) lootContext.getParameter(LootContextParams.ORIGIN));
|
|
|
|
- state.getDrops(lootContext).forEach((itemstack) -> {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(worldserver, blockposition, state.getDrops(lootContext)).forEach((itemstack) -> { // Parchment
|
|
Block.popResource(worldserver, blockposition, itemstack);
|
|
});
|
|
state.spawnAfterBreak(worldserver, blockposition, ItemStack.EMPTY, true);
|
|
@@ -316,7 +316,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
|
|
public static void dropResources(BlockState state, Level world, BlockPos pos) {
|
|
if (world instanceof ServerLevel) {
|
|
- Block.getDrops(state, (ServerLevel) world, pos, (BlockEntity) null).forEach((itemstack) -> {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, (BlockEntity) null)).forEach((itemstack) -> { // Parchment
|
|
Block.popResource(world, pos, itemstack);
|
|
});
|
|
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true);
|
|
@@ -326,7 +326,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
|
|
public static void dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity) {
|
|
if (world instanceof ServerLevel) {
|
|
- Block.getDrops(state, (ServerLevel) world, pos, blockEntity).forEach((itemstack) -> {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity)).forEach((itemstack) -> { // Parchment
|
|
Block.popResource((ServerLevel) world, pos, itemstack);
|
|
});
|
|
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true);
|
|
@@ -353,7 +353,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
|
|
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) {
|
|
if (world instanceof ServerLevel) {
|
|
- Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, stack).forEach((itemstack1) -> {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDropResourcesEvent(world, pos, Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, stack)).forEach((itemstack1) -> { // Parchment
|
|
Block.popResource(world, pos, itemstack1);
|
|
});
|
|
state.spawnAfterBreak((ServerLevel) world, pos, stack, true);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index e9847ba8dde5b9efb5214973f1399460ddcf930f..13e30a3ad79df17c180ba95ab9f41eb39f93e726 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -1967,5 +1967,19 @@ public class CraftEventFactory {
|
|
}
|
|
});
|
|
}
|
|
+
|
|
+ public static List<ItemStack> callBlockDropResourcesEvent(LevelAccessor world, BlockPos pos, List<ItemStack> items) {
|
|
+ List<org.bukkit.inventory.ItemStack> bukkitItems = new ArrayList<>(items.size());
|
|
+ for (ItemStack item : items) {
|
|
+ bukkitItems.add(CraftItemStack.asBukkitCopy(item));
|
|
+ }
|
|
+ gg.projecteden.parchment.event.block.BlockDropResourcesEvent event = new gg.projecteden.parchment.event.block.BlockDropResourcesEvent(CraftBlock.at(world, pos), bukkitItems);
|
|
+ event.callEvent();
|
|
+ items = new ArrayList<>(bukkitItems.size());
|
|
+ for (org.bukkit.inventory.ItemStack item : bukkitItems) {
|
|
+ items.add(CraftItemStack.asNMSCopy(item));
|
|
+ }
|
|
+ return items;
|
|
+ }
|
|
// Parchment end
|
|
}
|