Search in sources :

Example 1 with EntitySafariNet

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;
}
Also used : EntitySafariNet(powercrystals.minefactoryreloaded.entity.EntitySafariNet) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EntitySafariNet

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;
}
Also used : IPosition(net.minecraft.dispenser.IPosition) EntitySafariNet(powercrystals.minefactoryreloaded.entity.EntitySafariNet) EnumFacing(net.minecraft.util.EnumFacing) World(net.minecraft.world.World)

Aggregations

EntitySafariNet (powercrystals.minefactoryreloaded.entity.EntitySafariNet)2 IPosition (net.minecraft.dispenser.IPosition)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 World (net.minecraft.world.World)1