MsGamerHD

Untitled

Jul 10th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1.     private void startBrunnen() {
  2.         new BukkitRunnable() {
  3.            
  4.             @Override
  5.             public void run() {
  6.                 if(brunnen){
  7.                     Location mitte = Utils.getBrunnenmitte();
  8.                     for(int i = 1; i <= 4; i++){
  9.                         Location ecke = Utils.getLocation("brunnen_ecke_"+i, FileManager.getLocationFile());
  10.                        
  11.                         Vector v = new Vector(ecke.getBlockX()-mitte.getBlockX(), ecke.getBlockY()-mitte.getBlockY(), ecke.getBlockZ()-mitte.getBlockZ()).normalize();
  12.                         v.multiply(0.4D);
  13.                         v.setY(0.6D);
  14.                        
  15.                         dropBlock(mitte, 79, (byte) 11, v);
  16.                         for(Entity en : ecke.getWorld().getEntities()){
  17.                             if(en instanceof Item){
  18.                                 if(en.getLocation().distance(ecke) <=3){
  19.                                     Item item = (Item) en;
  20.                                     if(item.getItemStack().getType() == Material.ICE){
  21.                                         item.remove();
  22.                                     }
  23.                                 }
  24.                             }
  25.                             if(en instanceof FallingBlock){
  26.                                 if(en.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR
  27.                                         && en.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.COBBLE_WALL){
  28.                                     en.remove();
  29.                                 }
  30.                             }
  31.                         }
  32.                     }
  33.                 }
  34.             }
  35.         }.runTaskTimer(this, 0, 3);
  36.     }
  37.    
  38.     public void dropBlock(Location loc, int id, byte data, Vector vec) {
  39.         EntityFallingBlock entity = new EntityFallingBlock(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ(), Block.getById(id).fromLegacyData(data));
  40.         entity.ticksLived = 1;
  41.         ((CraftWorld) loc.getWorld()).getHandle().addEntity(entity, SpawnReason.CUSTOM);
  42.  
  43.         entity.getBukkitEntity().setVelocity(vec);
  44.     }
Add Comment
Please, Sign In to add comment