Posted March 24, 201411 yr Hi, I want to make my entity destroy blocks like a real player, meaning the damage state of the block should be computed the same way so the entity breaks block at the same speed a player would. How can i do it ? From ItemInWorldManager.updateBlockRemoving() i tried to sum up the computation, leading to a result like : onLivingUpdate() { [some other entity updates]; if(this.destroying_block) { ++this.curblockDamage; i = this.theWorld.getBlockId(this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ); Block block = Block.blocksList[i]; if (block == null) { this.theWorld.destroyBlockInWorldPartially(entityId, x,y,z, -1); this.destroying_block= false; } else { ItemStack items = inventory.getCurrentItem(); float f = items.getItem().getStrVsBlock(items,block,world.getBlockMetadata(x,y,z)); float hardness = block.getBlockHardness(world,x,y,z); int l = this.curBlockDamage; float f1 = f / hardness / 30F; float f2 = f1 * (l+1); float j = (int)( f2 * 10.0F ); this.theWorld.destroyBlockInWorldPartially(entityId, x,y,z, j); } } } where curBlockDamage is initialised to 0 when destroying block is set to true. Is this correct ? I don't really understand why there are so many steps and factors when computing j so I'm absolutely not sure. Moreover, what's the limit to know when the block is destroyed ? Thanks.
March 24, 201411 yr Author I had a look, and there's the same call to destroyBlockInWorldPartially() but it's a special case where the computation seems different as it's not similar to breaking a block with a tool.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.