Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. package net.madcrazydrumma.skyrimcraft.spell;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.item.EntityItem;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.util.math.AxisAlignedBB;
  7. import net.minecraft.util.math.Vec3d;
  8. import net.minecraft.util.text.TextComponentString;
  9. import net.minecraft.world.World;
  10.  
  11. import java.util.List;
  12.  
  13. public class FusRoDah
  14. {
  15. public static void cast(EntityPlayer player) {
  16. player.addChatComponentMessage(new TextComponentString("Fus... Ro Dah!"));
  17. AxisAlignedBB fanBox = getEffectAABB(player.worldObj, player);
  18. Vec3d lookVec = player.getLookVec();
  19.  
  20. fanEntitiesAABB(player.worldObj, player, fanBox);
  21. }
  22.  
  23. private static void fanEntitiesAABB(World world, EntityPlayer player, AxisAlignedBB fanBox) {
  24. Vec3d moveVec = player.getLookVec();
  25.  
  26. List<Entity> inBox = world.getEntitiesWithinAABBExcludingEntity(player, fanBox);
  27.  
  28. float force = 2.0F;
  29.  
  30. for (Entity entity : inBox) {
  31. if (entity.canBePushed() || entity instanceof EntityItem) {
  32. entity.addVelocity(moveVec.xCoord * force, moveVec.yCoord * force, moveVec.zCoord * force);
  33. }
  34. }
  35. }
  36.  
  37. private static AxisAlignedBB getEffectAABB(World world, EntityPlayer player) {
  38. double range = 3.0D;
  39. double radius = 2.0D;
  40.  
  41. Vec3d srcVec = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
  42. Vec3d lookVec = player.getLookVec();
  43. Vec3d destVec = srcVec.addVector(lookVec.xCoord * range, lookVec.yCoord * range, lookVec.zCoord * range);
  44.  
  45. AxisAlignedBB crumbleBox = new AxisAlignedBB(destVec.xCoord - radius, destVec.yCoord - radius, destVec.zCoord - radius, destVec.xCoord + radius, destVec.yCoord + radius, destVec.zCoord + radius);
  46.  
  47. return crumbleBox;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement