Search in sources :

Example 1 with ItemBow

use of net.minecraft.item.ItemBow in project Charset by CharsetMC.

the class CharsetTweakZorro method doTheZorroThing.

@SubscribeEvent
public void doTheZorroThing(PlayerInteractEvent.EntityInteract event) {
    EntityPlayer player = event.getEntityPlayer();
    if (player.world.isRemote)
        return;
    if (player.isRiding())
        return;
    if (!(event.getTarget() instanceof EntityHorse))
        return;
    EntityHorse horse = (EntityHorse) event.getTarget();
    if (player.fallDistance <= 2)
        return;
    if (!horse.isHorseSaddled())
        return;
    if (horse.getLeashed()) {
        if (!(horse.getLeashHolder() instanceof EntityLeashKnot))
            return;
        horse.getLeashHolder().processInitialInteract(player, EnumHand.MAIN_HAND);
    }
    boolean awesome = false;
    ItemStack heldStack = player.getHeldItem(EnumHand.MAIN_HAND);
    if (player.fallDistance > 5 && !heldStack.isEmpty()) {
        Item held = heldStack.getItem();
        boolean has_baby = false;
        if (player.getRidingEntity() instanceof EntityAgeable) {
            EntityAgeable ea = (EntityAgeable) player.getRidingEntity();
            has_baby = ea.isChild();
        }
        awesome = held instanceof ItemSword || held instanceof ItemBow || player.getRidingEntity() instanceof EntityPlayer || has_baby;
        if (!awesome) {
            Set<String> classes = held.getToolClasses(heldStack);
            awesome |= classes.contains("axe");
        }
    }
    if (awesome) {
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 40, 2, false, false));
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("resistance"), 20 * 40, 1, true, true));
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("jump_boost"), 20 * 40, 1, true, true));
    } else {
        horse.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("speed"), 20 * 8, 1, false, false));
    }
    horse.playLivingSound();
}
Also used : EntityLeashKnot(net.minecraft.entity.EntityLeashKnot) ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) EntityHorse(net.minecraft.entity.passive.EntityHorse) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityAgeable(net.minecraft.entity.EntityAgeable) ItemBow(net.minecraft.item.ItemBow) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemBow

use of net.minecraft.item.ItemBow in project BloodMagic by WayofTime.

the class EntityCorruptedZombie method setCombatTask.

@Override
public void setCombatTask() {
    if (!this.getEntityWorld().isRemote) {
        this.tasks.removeTask(this.aiAttackOnCollide);
        this.tasks.removeTask(this.aiArrowAttack);
        ItemStack itemstack = this.getHeldItemMainhand();
        if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
            int i = 20;
            if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
                i = 40;
            }
            this.aiArrowAttack.setAttackCooldown(i);
            this.tasks.addTask(attackPriority, this.aiArrowAttack);
        } else {
            this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow)

Example 3 with ItemBow

use of net.minecraft.item.ItemBow in project BloodMagic by WayofTime.

the class EntitySentientSpecter method setCombatTask.

@Override
public void setCombatTask() {
    if (!this.getEntityWorld().isRemote) {
        this.tasks.removeTask(this.aiAttackOnCollide);
        this.tasks.removeTask(this.aiArrowAttack);
        ItemStack itemstack = this.getHeldItemMainhand();
        if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemBow) {
            int i = 20;
            if (this.getEntityWorld().getDifficulty() != EnumDifficulty.HARD) {
                i = 40;
            }
            this.aiArrowAttack.setAttackCooldown(i);
            this.tasks.addTask(attackPriority, this.aiArrowAttack);
        } else {
            this.tasks.addTask(attackPriority, this.aiAttackOnCollide);
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow)

Example 4 with ItemBow

use of net.minecraft.item.ItemBow in project Wurst-MC-1.12 by Wurst-Imperium.

the class BowAimbotMod method onUpdate.

@Override
public void onUpdate() {
    // check if using item
    if (!mc.gameSettings.keyBindUseItem.pressed) {
        target = null;
        return;
    }
    if (!WMinecraft.getPlayer().isHandActive() && !wurst.mods.fastBowMod.isActive()) {
        target = null;
        return;
    }
    // check if item is bow
    ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
    if (item == null || !(item.getItem() instanceof ItemBow)) {
        target = null;
        return;
    }
    // set target
    if (!EntityUtils.isCorrectEntity(target, targetSettings))
        target = EntityUtils.getBestEntityToAttack(targetSettings);
    if (target == null)
        return;
    // set velocity
    velocity = (72000 - WMinecraft.getPlayer().getItemInUseCount()) / 20F;
    velocity = (velocity * velocity + velocity * 2) / 3;
    if (velocity > 1)
        velocity = 1;
    // adjust for FastBow
    if (wurst.mods.fastBowMod.isActive())
        velocity = 1;
    // set position to aim at
    double d = RotationUtils.getEyesPos().distanceTo(target.boundingBox.getCenter());
    double posX = target.posX + (target.posX - target.prevPosX) * d - WMinecraft.getPlayer().posX;
    double posY = target.posY + (target.posY - target.prevPosY) * d + target.height * 0.5 - WMinecraft.getPlayer().posY - WMinecraft.getPlayer().getEyeHeight();
    double posZ = target.posZ + (target.posZ - target.prevPosZ) * d - WMinecraft.getPlayer().posZ;
    // set yaw
    WMinecraft.getPlayer().rotationYaw = (float) Math.toDegrees(Math.atan2(posZ, posX)) - 90;
    // calculate needed pitch
    double hDistance = Math.sqrt(posX * posX + posZ * posZ);
    double hDistanceSq = hDistance * hDistance;
    float g = 0.006F;
    float velocitySq = velocity * velocity;
    float velocityPow4 = velocitySq * velocitySq;
    float neededPitch = (float) -Math.toDegrees(Math.atan((velocitySq - Math.sqrt(velocityPow4 - g * (g * hDistanceSq + 2 * posY * velocitySq))) / (g * hDistance)));
    // set pitch
    if (Float.isNaN(neededPitch))
        RotationUtils.faceEntityClient(target);
    else
        WMinecraft.getPlayer().rotationPitch = neededPitch;
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow)

Example 5 with ItemBow

use of net.minecraft.item.ItemBow in project Cavern2 by kegare.

the class EntityCavenicSkeleton method setCombatTask.

@Override
public void setCombatTask() {
    if (aiArrowAttack == null || aiAttackOnCollide == null) {
        initCustomAI();
    }
    if (world != null && !world.isRemote) {
        tasks.removeTask(aiAttackOnCollide);
        tasks.removeTask(aiArrowAttack);
        ItemStack heldMain = getHeldItemMainhand();
        if (!heldMain.isEmpty() && heldMain.getItem() instanceof ItemBow) {
            tasks.addTask(4, aiArrowAttack);
        } else {
            tasks.addTask(4, aiAttackOnCollide);
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow)

Aggregations

ItemBow (net.minecraft.item.ItemBow)10 ItemStack (net.minecraft.item.ItemStack)10 Item (net.minecraft.item.Item)3 ItemSword (net.minecraft.item.ItemSword)3 ItemArmor (net.minecraft.item.ItemArmor)2 ItemFishingRod (net.minecraft.item.ItemFishingRod)2 ItemTool (net.minecraft.item.ItemTool)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 WeightedItemStack (cavern.util.WeightedItemStack)1 Minecraft (net.minecraft.client.Minecraft)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 RenderManager (net.minecraft.client.renderer.entity.RenderManager)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLeashKnot (net.minecraft.entity.EntityLeashKnot)1 EntityHorse (net.minecraft.entity.passive.EntityHorse)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemFood (net.minecraft.item.ItemFood)1 ItemHoe (net.minecraft.item.ItemHoe)1