@Override public void onUpdate(BlockMaterial oldMaterial, Block block) { super.onUpdate(oldMaterial, block); if (!block.translate(BlockFace.BOTTOM).getMaterial().isPlacementObstacle()) { // turn this block into a mobile block Entity e = block .getWorld() .createAndSpawnEntity(block.getPosition(), FallingBlock.class, LoadOption.NO_LOAD); e.add(FallingBlock.class).setMaterial(this); block.setMaterial(VanillaMaterials.AIR); } }
public void move(double multiplier) { shootTime++; if (!alive) { if (deathWait) { deathWaitCount++; if (deathWaitCount > 50) { deathWait = false; if (hasItem()) item.reset(); resetLocation(); } } else { ghostCount++; if (ghostCount >= 100) alive = true; } } if (!deathWait) { double x = Math.cos(angle.getValue()) * speed * speedToggle * multiplier; double y = Math.sin(angle.getValue()) * speed * speedToggle * multiplier; for (Solid s : world.getSolids()) { boolean[] bools = s.collides(this); if (bools[0]) { if ((y > 0 && bools[1]) || (y < 0 && bools[2])) y = 0; if ((x > 0 && bools[3]) || (x < 0 && bools[4])) x = 0; } } // super.move(speed*multiplier*speedToggle); location.addX(x); location.addY(y); if (rotateToggle != 0) { if (Math.abs(rotateToggle) < maxRotateSpeed) rotate(rotateToggle); // go exact remainder of angle else rotate(rotateToggle * multiplier * maxRotateSpeed); } } }