mineItem.spawnEntity(facingBlock, Vector3f.ZERO);
slot.addAmount(-1);
return true;
}
} else if (item.getMaterial() instanceof BoatItem) {
Point placePos;
if (facingBlock.getMaterial() instanceof Water) {
placePos = facingBlock.getPosition().add(.5f, 1f, .5f);
} else if (facingBlock.getMaterial().equals(VanillaMaterials.AIR) && facingBlock.translate(BlockFace.BOTTOM).getMaterial() instanceof Water) {
placePos = facingBlock.getPosition().add(.5f, 0f, .5f);
} else {
return false;
}
Boat boat = ((BoatItem) item.getMaterial()).spawnEntity(placePos);
block.getWorld().spawnEntity(boat.getOwner());
slot.addAmount(-1);
return true;
} else {
// Try to shoot the item selected if we can't do anything else with it
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) {