use of am2.entities.EntityBroom in project ArsMagica2 by Mithion.
the class ItemRune method spawnBroom.
public void spawnBroom(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote) {
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, true);
if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK) {
TileEntity te = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (te instanceof IInventory) {
EntityBroom broom = new EntityBroom(world);
broom.setPosition(player.posX, player.posY, player.posZ);
broom.setChestLocation(new AMVector3(mop.blockX, mop.blockY, mop.blockZ));
world.spawnEntityInWorld(broom);
}
}
}
}
use of am2.entities.EntityBroom in project ArsMagica2 by Mithion.
the class ItemMagicBroom method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, true);
if (mop != null && mop.typeOfHit == MovingObjectType.BLOCK) {
TileEntity te = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (te instanceof IInventory) {
EntityBroom broom = new EntityBroom(world);
broom.setPosition(player.posX, player.posY, player.posZ);
broom.setChestLocation(new AMVector3(mop.blockX, mop.blockY, mop.blockZ));
world.spawnEntityInWorld(broom);
stack.stackSize--;
if (stack.stackSize == 0) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
return true;
}
}
}
return false;
}
Aggregations