Skip to content

Add BlockBreakBlockEvent#4989

Merged
Machine-Maker merged 1 commit into
PaperMC:masterfrom
Machine-Maker:feature/BlockBreadBlockDropItemEvent
Aug 25, 2021
Merged

Add BlockBreakBlockEvent#4989
Machine-Maker merged 1 commit into
PaperMC:masterfrom
Machine-Maker:feature/BlockBreadBlockDropItemEvent

Conversation

@Machine-Maker
Copy link
Copy Markdown
Member

So not really sure what to call this event, but there wasn't a way to affect the drops when water or a piston breaks a block. So this adds that. Kind of an odd name I know, but if you've got a better one, suggest away please.

@Machine-Maker Machine-Maker requested a review from a team as a code owner January 4, 2021 02:00
@ExcessiveAmountsOfZombies
Copy link
Copy Markdown
Contributor

EnvironmentalBlockDropEvent? ExternalBlockDropEvent?

@electronicboy
Copy link
Copy Markdown
Member

I got an idea.
Kassssshhhhhh, bring ur wisdoms

@Geolykt
Copy link
Copy Markdown

Geolykt commented Jan 17, 2021

BlockReplacementEvent (this is a shit suggestion) or a variation thereof (such as BlockReplacedEvent or ReplacedBlockDropEvent) as the block is destroyed so another block (in this case either liquid or piston head) is set on where the old block once was

@aurorasmiles
Copy link
Copy Markdown
Contributor

BlockBreakByEnvironmentItemDropEvent :D

@stefvanschie
Copy link
Copy Markdown
Contributor

I like ExternalBlockDropEvent as suggested by ExcessiveAmountOfZombies.

@yannicklamprecht
Copy link
Copy Markdown
Contributor

DropItemByEnvironmentalBlockBreakEvent

@Phoenix616
Copy link
Copy Markdown
Contributor

Phoenix616 commented Jan 17, 2021

Imo. the naming difficulty exposes a completely different issue: The event only gets called on a block drop, not on the block break making it impossible to cancel that event as well as getting the drop. Imo. that should be combined to one event which both handles the actual block breaking as well as the drop catching. Edit: Granted, the implementation might not be possible that way and the Player block breaking also consists of two events (which I don't really like) :S

That could also make the naming easier:

  • BlockBlockBreakEvent
  • EnvironmentBlockBreakEvent
  • stranger but might sound better: BlockBreakBlockEvent

@Machine-Maker Machine-Maker force-pushed the feature/BlockBreadBlockDropItemEvent branch from 6b4d91f to 497f6a4 Compare May 24, 2021 18:34
@Machine-Maker Machine-Maker requested a review from a team as a code owner May 24, 2021 18:34
@Machine-Maker
Copy link
Copy Markdown
Member Author

K, rebased (somehow I forgot this one after md_5's nms repackage), and I went with BlockBreakBlockEvent

@Machine-Maker Machine-Maker force-pushed the feature/BlockBreadBlockDropItemEvent branch from 497f6a4 to d1216e9 Compare July 8, 2021 02:55
@Machine-Maker
Copy link
Copy Markdown
Member Author

Rebased for 1.17.1

@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: rebase required labels Jul 8, 2021
Comment thread patches/server/0725-Add-BlockBreakBlockEvent.patch Outdated
@Machine-Maker Machine-Maker force-pushed the feature/BlockBreadBlockDropItemEvent branch from d1216e9 to 2a6f0da Compare July 10, 2021 02:14
@qixils
Copy link
Copy Markdown
Contributor

qixils commented Jul 10, 2021

a BlockDropResourcesEvent that gets called for every #dropResources call would be nice for modifying i.e. drops of decaying leaves which aren't explicitly caused by another block. this event could extend that as well? probably out of scope for this PR, just figured i'd note it here since it's pretty similar, and it's a feature i wanted so much i implemented it myself not too differently from this PR :P (yes, it uses streams, i'll fix it eventually)

@Brokkonaut
Copy link
Copy Markdown
Contributor

Is there anything still blocking this PR? This feature would be really helpful for the plugin I am currently creating...

Copy link
Copy Markdown
Contributor

@Proximyst Proximyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

+ public static boolean dropResources(BlockState blockState, LevelAccessor generatorAccess, BlockPos blockPosition, BlockPos source, @Nullable BlockEntity tileEntity) {
+ if (generatorAccess instanceof ServerLevel) {
+ List<org.bukkit.inventory.ItemStack> items = com.google.common.collect.Lists.newArrayList();
+ for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(blockState, generatorAccess.getMinecraftWorld(), blockPosition, tileEntity)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully qualified name here could be replaced with var but it's no biggie

@Machine-Maker Machine-Maker changed the title Add BlockBreakBlockDropItemEvent Add BlockBreakBlockEvent Aug 25, 2021
@Machine-Maker Machine-Maker force-pushed the feature/BlockBreadBlockDropItemEvent branch from 2a6f0da to 260ef1a Compare August 25, 2021 01:39
@Machine-Maker Machine-Maker enabled auto-merge (squash) August 25, 2021 01:39
@Machine-Maker Machine-Maker merged commit 61a09c5 into PaperMC:master Aug 25, 2021
@Machine-Maker Machine-Maker deleted the feature/BlockBreadBlockDropItemEvent branch August 25, 2021 01:42
LeonTG pushed a commit to LeonTG/Paper that referenced this pull request May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.