BentoBoxWorld / Limits

Limits blocks and entities on islands - for BentoBox
Eclipse Public License 2.0
8 stars 17 forks source link

Bad counting of different blocks #110

Open organizatsiya opened 3 years ago

organizatsiya commented 3 years ago

Description Hello, The system for calculating limits is flawed for blocks that grow from several blocks. For example, if you put a cactus, +1 is added to the limit but when it grows by 1 block and you break it, -1 is added to the limit which makes 0 while there is still a block of cactus. On the other hand, if you break the block of sand under the cactus, it drops and yet the limit is still +1. Same for sugar cane and bamboo

For campfires, if you put a campfire, the limit adds +1, if you turn it off and then relight it, the limit adds +1 while it's the same campfire, hence a limit result of +2 for a single campfire.

BONNe commented 3 years ago

I am not saying that it should not be fixed, but I am just curious... why do you limit bamboo, cactus, and campfires?

I think flowers had the same issue, but not sure if it is fixed.

organizatsiya commented 3 years ago

I limit cactus and sugar cane so as not to have gigantic farms on the server because I want to be able to provide sand at a reduced price to promote concrete constructions

tastybento commented 3 years ago

Unfortunately, this is extremely hard to track because events are not fired for these kinds of breakages because the player is not involved with it. Actually it may be impossible to track this. That is why there is a recount command for the player to run. If they think the limits are wrong.

organizatsiya commented 3 years ago

And why not just check that when you place or break one of these blocks there is a block of sand or dirt underneath? if it's true, +1 or -1, if it's false, do nothing

Edit: coarse dirt, mycelium, podzol, farmland, dirt, grass, red sand, sand

tastybento commented 3 years ago

It's not that - say that the plant is on a block and something breaks that block, then the whole plant is destroyed. In that case, there is no Bukkit event that is fired. The underlying block can be broken in many ways that are not related to players. So, the addon assume the plant is still there. That's the problem. It will over-count, so that's why the player can ask for a recount if they disagree.

BONNe commented 3 years ago

Tasty, that is not entirely correct.

Bukkit will call the event: BlockPhysicsEvent. It is not called, only if a block is voided or replaced with a physic update suppression. But in these situations. the plant will still float.

It is never recommended to use this event due to the fact, that it is called 7 times per single block. So any check done with this event should be very, very fast. Otherwise, it will impact the server very hard.