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();
}
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);
}
}
}
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);
}
}
}
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;
}
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);
}
}
}
Aggregations