skyboy / MineFactoryReloaded

104 stars 75 forks source link

Block Placer Dupe Bug #444

Closed Sir-Will closed 9 years ago

Sir-Will commented 9 years ago

If the block in front of the block placer get broken by a block breaker for example the one from openblocks it will place the block again but it also keeps the item. This seems to only work with the combination of OpenBlocks breaker and MFR placer. Useing a other breaker or placer doesn't reproduce this issue.

Setup: http://i.imgur.com/rzAZ0HS.png

skyboy commented 9 years ago

This is an issue with OpenBlocks.

Sir-Will commented 9 years ago

Ok, opened an issue there: https://github.com/OpenMods/OpenBlocks/issues/649

boq commented 9 years ago

This is an issue with OpenBlocks.

Questionable. MFR is also doing risky operation.

Let me explain how both blocks interact. You probably figured out out same thing before you commented, but it will be easier to discuss if it's written somewhere.

From what I see, you have following code:

What actually happens

Now, OB block breaker works on updates, without delay. I'm not really sure how most people use it, but I'm almost sure I will get complaints about broken builds if I switch it to "rising edge" instead of "update + high signal" detection.

On the other hand, I'm not really sure that get-set behaviour makes code more secure. Vanilla code has similar check (ItemBlock.placeBlockAt), but skips item stack decrement only if World.setBlock fails (only item callback are skipped). Why your code is more restrictive? There was some bug when item were lost, but no block was placed?

skyboy commented 9 years ago

Issues with how other structures would handle replacing destroyed elements and some protection zones. The problem is that the block is broken on the update: if you triggered an update via the standard scheduled block updates or your tile ticks and you set a flag, it would ensure you're not running your logic while someone else's logic is running (see: MFR's block breaker).

boq commented 9 years ago

And about hour after noticing initial issue I did exactly that.

I was just wondering what made you write that restriction. Most world protection hooks are placed much earlier, so I'm not sure if anything is gained. But that's not in scope of this issue.