use of powercrystals.minefactoryreloaded.entity.EntitySafariNet in project MineFactoryReloaded by powercrystals.
the class ItemSafariNetLauncher method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (player.isSneaking()) {
stack.setItemDamage(stack.getItemDamage() == 0 ? 1 : 0);
if (world.isRemote) {
if (isCaptureMode(stack)) {
player.sendChatToPlayer("Changed to capture mode");
} else {
player.sendChatToPlayer("Changed to release mode");
}
}
return stack;
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack ammo = player.inventory.getStackInSlot(i);
if (ammo != null && ammo.getItem() instanceof ItemSafariNet) {
if ((ItemSafariNet.isEmpty(ammo) && isCaptureMode(stack)) || (!ItemSafariNet.isEmpty(ammo) && !isCaptureMode(stack))) {
if (!world.isRemote) {
EntitySafariNet esn = new EntitySafariNet(world, player, ammo);
world.spawnEntityInWorld(esn);
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
}
player.inventory.setInventorySlotContents(i, null);
break;
}
}
}
return stack;
}
use of powercrystals.minefactoryreloaded.entity.EntitySafariNet in project MineFactoryReloaded by powercrystals.
the class BehaviorDispenseSafariNet method dispenseStack.
@Override
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack stack) {
World world = dispenser.getWorld();
IPosition dispenserPos = BlockDispenser.getIPositionFromBlockSource(dispenser);
EnumFacing dispenserFacing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
EntitySafariNet proj = new EntitySafariNet(world, dispenserPos.getX(), dispenserPos.getY(), dispenserPos.getZ(), stack.copy());
proj.setThrowableHeading(dispenserFacing.getFrontOffsetX(), dispenserFacing.getFrontOffsetY() + 0.1, dispenserFacing.getFrontOffsetZ(), 1.1F, 6.0F);
world.spawnEntityInWorld(proj);
stack.splitStack(1);
return stack;
}
Aggregations