[SPIGOT-466] Event fired on blockplaceevent doesnt properly listen to plugins when modifying the itemstack being placed Created: 23/Jan/15  Updated: 20/Mar/18

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: rourke Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: Craftbukkit, bug

Plugin: Citadel

 Description   

When using citadel I noticed the bug. What happens in the plugin is a block is placed and then it takes a specified block out of your inventory as well which acts as a reinforcement. So lets say you need diamonds in your inventory when placing a stone block which is in your hotbar and placing a stone block. It removes the stone block and removes the diamond. Now lets say you are placing stone and need stone for it. You have two item stacks of Stone, one in the 1 hotbar postion and another one is the second. You are placing from the second. It currently takes from the first position and the stone being placed is gone as well as the additional stone.

The bug happens when you modify the itemstack that is currently being placed. So if you have stone in your first place hotbar and you need stone and then you place the block, the plugin removes the one stone but only one stone is removed from the player's hotbar.



 Comments   
Comment by Stuperfied [ 20/Mar/18 ]

Appears intentional by design.

There is a check in;
\craftbukkit\src\main\java\net\minecraft\server\ItemStack.java line 220

 

219 // Change the stack to its new contents if it hasn't been tampered with. 
220 if (this.getCount() == oldCount && this.getData() == oldData) {

 

Possibly a workaround for a block or duplication glitch.

What if;
The original stack size was 1?
A plugin changed the stack to another material?
The item is not stackable?

An alternate method could be to gather data from the event and effect changes on a subsequent tick.

 

Comment by rourke [ 22/May/15 ]

So any news on this?

Comment by md_5 [ 30/Jan/15 ]

It will be fixed when we are able to.

Comment by rourke [ 29/Jan/15 ]

Have you confirmed this or do I need to modify my plugin?

Comment by rourke [ 25/Jan/15 ]

I found a link to part of the old thread: https://gist.github.com/turt2live/9568ad7daae3ab137d60

Comment by rourke [ 25/Jan/15 ]

That's what it should be.

Comment by md_5 [ 25/Jan/15 ]

The expected result would be:

[19:51:45 INFO]: In current hand: 27
[19:51:45 INFO]: New amount set: 26
[19:51:45 INFO]: After event fired 25

Right?

Comment by rourke [ 25/Jan/15 ]

Lol, I went through this process with craftbukkit too. Then as soon as it gets acknowledged the whole dmca thing happens. Gimme a minute to write something up.

Comment by md_5 [ 25/Jan/15 ]

Lets try another approach: write the smallest plugin you can to reproduce this issue.

Comment by rourke [ 25/Jan/15 ]

Sorry I suck at trying to describe, lets try this imgur link: http://imgur.com/a/oocWi

Comment by md_5 [ 24/Jan/15 ]

Can you please try and explain this more clearly using a format such as.
1) Player places stone
2) Plugin sets player's item in hand to dirt
3) Something happens

Something else should happen instead...

I don't understand what the issue you are trying to articulate is, sorry

Generated at Sat Apr 05 06:16:38 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.