Projectile Scripts
Creating a Projectile Script
public class FallingBlockScript extends ProjectileScript<AProjectile> {
private Object data; // either BlockData (1.13+) or MaterialData (1.12-)
public FallingBlockScript(@NotNull Plugin owner, @NotNull AProjectile projectile) {
super(owner, projectile);
if (projectile.getDisguise() == null || projectile.getDisguise().getType() != EntityType.FALLING_BLOCK)
throw new IllegalArgumentException("Tried to attach to " + projectile + " when it doesn't have falling block");
data = projectile.getDisguise().getData();
}
@Override
public void onTickEnd() {
Configuration config = WeaponMechanicsCosmetics.getInstance().getConfiguration();
int amount = config.getInt("Explosion_Effects.Falling_Block_Dust.Amount");
double spread = config.getDouble("Explosion_Effects.Falling_Block_Dust.Spread");
if (amount != 0) {
World world = projectile.getWorld();
Location location = projectile.getLocation().toLocation(world);
world.spawnParticle(Particle.FALLING_DUST, location, amount, spread, spread, spread, data);
}
}
}Projectile Script Manager
Registering the Script Manager
Last updated