I noticed when breaking instant mineable blocks in adventure mode while holding the key down, there is no swing animation which looks very weird. In creative with sword or survival this doesnt happen.
I'm not sure what causes this but it is noted as a bug until 1.8, which "fixed" this by requiring a tool to mine any block (hence the resolution as invalid instead of fixed; a related glitch with the breaking animation is still open):
As far as the code goes, there are many locations where the game checks if a player is in Adventure mode and can break a block with the appropriate tool that look like this (in this case, true if the player is not in Adventure or is holding an appropriate tool):
public void onBlockClicked(int par1, int par2, int par3, int par4)
{
if (!this.gameType.isAdventure() || this.thisPlayerMP.isCurrentToolAdventureModeExempt(par1, par2, par3))
I found one major exception in the Minecraft.java class, which only checks if the current tool can break a block in Adventure mode, but it should affect all game modes from the looks of things ("isCurrentToolAdventureModeExempt" doesn't check the player's game mode, just if a block can be harvested in Adventure mode):
Just to be sure, I commented out the if-statement and it fixed the issue but now you continuously punch blocks that can't be broken (which could still be acceptable); I looked again at "isCurrentToolAdventureModeExempt" and noticed that "capabilities.allowEdit" is set to false in Adventure mode, so it is in fact checking the game mode, otherwise, the game checks if the block can be broken in Adventure mode by first checking its material (which should return true for plants), then if the current held item can harvest it, so I'm not sure why it isn't working.
I found the issue. It seems that there are multiple passes on the client, like preBlockBreak, blockBreak and pastBlockBreak. And in the 3rd pass the block is already broken if its hardness is zero (instant).
Because it checks if there is air, it returns false for isCurrentToolAdventureModeExempt, therefore not causing the swing animation.
Code:
public boolean isCurrentToolAdventureModeExempt(int par1, int par2, int par3) {
if (this.capabilities.allowEdit) {
return true;
}
else {
int l = this.worldObj.getBlockId(par1, par2, par3);
// if block is air then return always true
if (l == 0) {
return true;
}
Block block = Block.blocksList[l];
if (block.blockMaterial.isAdventureModeExempt()) {
return true;
}
if (this.getCurrentEquippedItem() != null) {
ItemStack itemstack = this.getCurrentEquippedItem();
if (itemstack.canHarvestBlock(block) || itemstack.getStrVsBlock(block) > 1.0F) {
return true;
}
}
return false;
}
}
I noticed when breaking instant mineable blocks in adventure mode while holding the key down, there is no swing animation which looks very weird. In creative with sword or survival this doesnt happen.
Anyone an idea what the issue could be?
Minecraft 1.6.4 Performance Comparison
I'm not sure what causes this but it is noted as a bug until 1.8, which "fixed" this by requiring a tool to mine any block (hence the resolution as invalid instead of fixed; a related glitch with the breaking animation is still open):
MC-6315 Adventure mode animation not playing after 1 swing when breaking insta-breakable blocks
As far as the code goes, there are many locations where the game checks if a player is in Adventure mode and can break a block with the appropriate tool that look like this (in this case, true if the player is not in Adventure or is holding an appropriate tool):
I found one major exception in the Minecraft.java class, which only checks if the current tool can break a block in Adventure mode, but it should affect all game modes from the looks of things ("isCurrentToolAdventureModeExempt" doesn't check the player's game mode, just if a block can be harvested in Adventure mode):
Just to be sure, I commented out the if-statement and it fixed the issue but now you continuously punch blocks that can't be broken (which could still be acceptable); I looked again at "isCurrentToolAdventureModeExempt" and noticed that "capabilities.allowEdit" is set to false in Adventure mode, so it is in fact checking the game mode, otherwise, the game checks if the block can be broken in Adventure mode by first checking its material (which should return true for plants), then if the current held item can harvest it, so I'm not sure why it isn't working.
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
I found the issue. It seems that there are multiple passes on the client, like preBlockBreak, blockBreak and pastBlockBreak. And in the 3rd pass the block is already broken if its hardness is zero (instant).
Because it checks if there is air, it returns false for isCurrentToolAdventureModeExempt, therefore not causing the swing animation.
Code:
Minecraft 1.6.4 Performance Comparison