Minecraft-Server-Mod icon indicating copy to clipboard operation
Minecraft-Server-Mod copied to clipboard

Destroyed blocks not getting "break block" status

Open M4411K4 opened this issue 14 years ago • 4 comments

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.

M4411K4 avatar Mar 03 '11 01:03 M4411K4

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.

liquidox avatar Mar 03 '11 15:03 liquidox

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.

14mRh4X0r avatar Mar 03 '11 21:03 14mRh4X0r

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 avatar Mar 03 '11 23:03 M4411K4

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

M4411K4 avatar Mar 04 '11 18:03 M4411K4