Advertisement
LostKitty

TickEvent spawn anything (cause of arrow hits ground)

May 29th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.32 KB | None | 0 0
  1. @SubscribeEvent
  2.     public void tickupdate(TickEvent evt) {
  3.         Random myrandomgen = new Random();
  4.  
  5.  
  6.         for (Entity ee : entitylist) {
  7.             boolean ground = false;
  8.  
  9.  
  10.  
  11.             if (!ee.isDead) {
  12.  
  13.                 double lastposx = ee.lastTickPosX;
  14.                 double lastposy = ee.lastTickPosY;
  15.                 double lastposz = ee.lastTickPosZ;
  16.  
  17.                 double currentx = ee.posX;
  18.                 double currenty = ee.posY;
  19.                 double currentz = ee.posZ;
  20.                 double diffx = 0;
  21.                 double diffy = 0;
  22.                 double diffz = 0;
  23.                 boolean differencemajor = false;
  24.  
  25.                 //Get difference in X since last Tick
  26.                 if (lastposx > currentx) {
  27.                     diffx = lastposx - currentx;
  28.                 }
  29.                 if (currentx > lastposx) {
  30.                     diffx = currentx - lastposx;
  31.                 }
  32.  
  33.                 //Get difference in Y since last Tick
  34.                 if (lastposy > currenty) {
  35.                     diffy = lastposy - currenty;
  36.                 }
  37.                 if (currenty > lastposy) {
  38.                     diffy = currenty - lastposy;
  39.                 }
  40.                 //Get difference in Z since last Tick
  41.                 if (lastposz > currentz) {
  42.                     diffz = lastposz - currentz;
  43.                 }
  44.                 if (currentz > lastposz) {
  45.                     diffz = currentz - lastposz;
  46.                 }
  47.  
  48.                 if (diffx < 1) {
  49.                     if (diffy < 1) {
  50.                         if (diffz < 1) {
  51.                             differencemajor = true;
  52.                         }
  53.                     }
  54.  
  55.                 }
  56.  
  57.  
  58.                 if (thisplayer != null) {
  59.                     if (thisplayer.getEntityWorld().isRemote == false) {
  60.                         if (differencemajor == true) {
  61.                             EntitySpider tntentity;
  62.                             net.minecraft.entity.Entity thisarrow;
  63.                             net.minecraft.world.World world;
  64.                             world = ee.getEntityWorld();
  65.                             thisarrow = ee;
  66.  
  67.                             tntentity = new EntitySpider(thisplayer.getEntityWorld());
  68.                             tntentity.setLocationAndAngles(ee.posX, ee.posY, ee.posZ, 0, 0);
  69.                             world.spawnEntityInWorld(tntentity);
  70.  
  71.                             for (int a=1;a<300;a++){
  72.                                 int posx = myrandomgen.nextInt(200);
  73.                                 int posy = myrandomgen.nextInt(30);
  74.                                 int posz = myrandomgen.nextInt(200);
  75.  
  76.                                 double newx = (double)posx + ee.posX;
  77.                                 double newy = (double)posy + ee.posY;
  78.                                 double newz = (double)posz + ee.posZ;
  79.                                 tntentity = new EntitySpider(thisplayer.getEntityWorld());
  80.                                 tntentity.setLocationAndAngles(newx, newy, newz, 0, 0);
  81.                                 world.spawnEntityInWorld(tntentity);
  82.  
  83.  
  84.  
  85.  
  86.  
  87.                             }
  88.  
  89.  
  90.  
  91.                             ee.setDead();
  92.  
  93.                         }
  94.                     }
  95.                 }
  96.  
  97.  
  98.             }
  99.         }
  100.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement