final Random rand = GenericMath.getRandom();
Vector3f direction = this.getFacing(block).getOffset();
// Calculate position to shoot from
Point position = block.getPosition().add(direction.mul(0.6));
VanillaEntityComponent toLaunch = null;
// Calculate shooting velocity using facing direction
Vector3f velocity = direction.mul(rand.nextDouble() * 0.1 + 0.2);
// Set velocity y to above (0.2)
velocity = velocity.mul(1.0, 0.0, 1.0).add(0.0, 0.2, 0.0);
velocity = velocity.add(0.045 * rand.nextGaussian(), 0.045 * rand.nextGaussian(), 0.045 * rand.nextGaussian());
Effect shootEffect;
Material material = item.getMaterial();
//TODO: Implement the following 'special' shoot cases:
// - eggs, arrows, fireballs and snowballs
// - potions, exp. bottles, monster eggs
// - armor,
if (material.equals(VanillaMaterials.ARROW)) {
shootEffect = GeneralEffects.RANDOM_BOW;
toLaunch = new Arrow();
} else if (material.equals(VanillaMaterials.EGG)) {
shootEffect = GeneralEffects.RANDOM_BOW;
//TODO: Spawn
} else if (material.equals(VanillaMaterials.SNOWBALL)) {
shootEffect = GeneralEffects.RANDOM_BOW;
//TODO: Spawn
} else if (material instanceof PotionItem && ((PotionItem) material).isSplash()) {
shootEffect = GeneralEffects.RANDOM_BOW;
//TODO: Spawn
} else if (material.equals(VanillaMaterials.BOTTLE_O_ENCHANTING)) {
shootEffect = GeneralEffects.RANDOM_BOW;
//TODO: Spawn
} else if (material instanceof SpawnEgg) {
shootEffect = GeneralEffects.RANDOM_BOW;
//TODO: Spawn
} else if (material.equals(VanillaMaterials.FIRE_CHARGE)) {
shootEffect = GeneralEffects.SHOOT_FIREBALL;
//TODO: Spawn
} else {
shootEffect = GeneralEffects.RANDOM_CLICK1;
position = position.sub(0.0, 0.3, 0.0);
toLaunch = new Item();
((Item) toLaunch).setItemStack(item);
}
if (toLaunch != null) {
block.getWorld().createAndSpawnEntity(position, LoadOption.NO_LOAD, toLaunch.getClass());
}
shootEffect.playGlobal(block.getPosition());
GeneralEffects.SMOKE.playGlobal(block.getPosition(), direction);
return true;
}