Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Destroyed blocks not getting "break block" status #260

Open
M4411K4 opened this issue Mar 3, 2011 · 4 comments
Open

Destroyed blocks not getting "break block" status #260

M4411K4 opened this issue Mar 3, 2011 · 4 comments
Labels

Comments

@M4411K4
Copy link

M4411K4 commented Mar 3, 2011

In ONetServerHandler.java
The value of "paramOPacket14BlockDig.e" appears to never be "3" anymore when destroying a block.
This causes "block.setStatus(3);" on line# 312 to never be reached, where the block status of 3 is supposed to be the "broken block" state.

I could be wrong, but in my tests the OPacket14BlockDig class was no longer getting the "3" value for variable e, suggesting block break status has changed in minecraft.

If true, hMod will need to be updated to trigger the BLOCK_DESTROYED hook with the set block status of 3 at the appropriate time, or plugins that use the Block getStatus() value will need to be updated to use the "stopped digging" status (2) instead.

@liquidox
Copy link

liquidox commented Mar 3, 2011

Could this be causing the block lag we've been having in 1.3 and hmod135?

Been thinking it's a MC issue, but apparently it's no longer present in a recent Bukkit version, so it can be fixed.

Basically, while mining, blocks constantly pop back randomly, making it take about twice the amount of time to mine.

@14mRh4X0r
Copy link
Contributor

jeb_ redid digging in 1.3 to prevent intstant mining IIRC (I remember being pointed to his twitter). In decompiled code, status 1 was removed, but 3 is still there, which has lead me to believe nothing much has changed. I haven't done proper research when updating the code, so errors could've slipped into it.

@M4411K4
Copy link
Author

M4411K4 commented Mar 3, 2011

yah, I noticed that status 1 was removed. My tests were only showing status 0 and 2 being sent. There can be more statuses, but I wasn't seeing them when breaking basic blocks.

Looking at bukkit's NetServerHandler.java, they handle their "block broken" (3) status by getting the amount of damage from the block (using OBlock's a(OEntityPlayer) method) and on status 0 they check if the damage is 1 or greater. If the damage is 1 or more, then they send out the "block broken" status, otherwise, they send the "started digging" status.
They appear to keep status 2 as a "stopped digging" status, as hMod currently has.

Status 2 in my not so thorough tests were being sent on block breaks, but not for blocks such as redstone dust or the new redstone diodes. So my previous suggestion of plugins updating to use status 2 was wrong. This looks like something hMod needs to probably update.

I don't know if this issue is related to liquidox's mention of block lag, but it is the cause of Craftbook's apple drop feature from not working.

@M4411K4
Copy link
Author

M4411K4 commented Mar 4, 2011

So going back to the previous minecraft server 1.2x and testing, I was getting:
0 = started digging or broken status for one-hit blocks like redstonedust
1 = repeated as long as the player was digging
2 = when ever the player stopped digging
3 = when a block (other than the one-hit ones) were broken

and now it's:
0 = same
2 = when a block (other than the one-hit ones) were broken

So in ONetServerHandler.java
line# 305
block.setStatus(2);
should be changed to:
block.setStatus(3);

And after line# 293, it is recommended to add:
float damage = 0.0F;
if(OBlock.m[block.getType()] != null)
damage = OBlock.m[block.getType()].a(player.getEntity());
if(damage >= 1.0F)
block.setStatus(3); // Block will be destroyed. Usually one-hit blocks like redstone dust, and similar
else

This recommendation isn't necessary as plug-ins obviously haven't needed it so far, but it would set the correct internal state.

Also, it would be nice if we could use the proper status number 2 as the new block break status, since that's what it is now, but it's better for plug-ins that the internal status as 3 is kept since that's how it is defined in hMod

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants