Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.alureon.overdrive.aura;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import org.alureon.overdrive.Overdrive;
- import net.minecraft.src.Entity;
- import net.minecraft.src.EntityLiving;
- import net.minecraft.src.MathHelper;
- import net.minecraft.src.Packet12PlayerLook;
- /**
- * Allows us to attack an entity.
- * @author Alureon
- */
- public class Attack implements Runnable {
- private boolean look;
- private boolean silent;
- private Entity entity;
- /**
- * @param e
- * The entity to attack.
- * @param look
- * Shall we look at the entity?
- * @param silent
- * Shall we face the entity server-sided?
- */
- public Attack(Entity e, boolean look, boolean silent) {
- this.entity = e;
- this.look = look;
- this.silent = silent;
- ExecutorService es1 = Executors.newSingleThreadExecutor();
- es1.submit(this);
- }
- /**
- * Changes pitch and yaw so that the entity calling the function is facing the entity provided as an argument. Taken from EntityLiving.java.
- * @param par1Entity
- * The entity to face
- */
- public void faceEntity(Entity par1Entity, float par2, float par3)
- {
- double var4 = par1Entity.posX - Overdrive.getWrapper().getPlayer().posX;
- double var6 = par1Entity.posZ - Overdrive.getWrapper().getPlayer().posZ;
- double var8;
- if (par1Entity instanceof EntityLiving)
- {
- EntityLiving var10 = (EntityLiving)par1Entity;
- var8 = var10.posY + (double)var10.getEyeHeight() - (Overdrive.getWrapper().getPlayer().posY + (double)Overdrive.getWrapper().getPlayer().getEyeHeight());
- }
- else
- {
- var8 = (par1Entity.boundingBox.minY + par1Entity.boundingBox.maxY) / 2.0D - (Overdrive.getWrapper().getPlayer().posY + (double)Overdrive.getWrapper().getPlayer().getEyeHeight());
- }
- double var14 = (double)MathHelper.sqrt_double(var4 * var4 + var6 * var6);
- float var12 = (float)(Math.atan2(var6, var4) * 180.0D / Math.PI) - 90.0F;
- float var13 = (float)(-(Math.atan2(var8, var14) * 180.0D / Math.PI));
- if(!silent) {
- Overdrive.getWrapper().getPlayer().rotationPitch = Overdrive.getWrapper().getPlayer().updateRotation(Overdrive.getWrapper().getPlayer().rotationPitch, var13, par3);
- Overdrive.getWrapper().getPlayer().rotationYaw = Overdrive.getWrapper().getPlayer().updateRotation(Overdrive.getWrapper().getPlayer().rotationYaw, var12, par2);
- } else {
- Overdrive.getWrapper().getSendQueue().addToSendQueue(new Packet12PlayerLook(var12, var13, Overdrive.getWrapper().getPlayer().onGround));
- }
- }
- @Override
- public void run() {
- if(look) {
- faceEntity(entity, 100F, 100F);
- }
- Overdrive.getWrapper().getPlayer().swingItem();
- Overdrive.getWrapper().getPlayerController().attackEntity(Overdrive.getWrapper().getPlayer(), entity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement