first implementaion of a custom TickHandler

This commit is contained in:
2016-07-19 13:18:41 +02:00
parent 7a72051cb4
commit 74e3baa05c
5 changed files with 72 additions and 7 deletions

View File

@@ -19,11 +19,13 @@ public class TraitCascade extends AbstractTrait {
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
float f = random.nextFloat();
float b = 0.99F * calcBonus(tool);
if (!world.isRemote && tool.canHarvestBlock(state) && f <= b) {
double x, y, z, sx, sy, sz;
sx = x = pos.getX();
sy = y = pos.getY();
sz = z = pos.getZ();
for (int i = random.nextInt(ToolHelper.getCurrentDurability(tool)); i > 0; i--) {
int r = random.nextInt(3);
int d = random.nextBoolean() ? 1 : -1;
@@ -42,11 +44,8 @@ public class TraitCascade extends AbstractTrait {
y = sy;
z = sz;
}
}
}
}
private float calcBonus(ItemStack tool) {