Guest User

Untitled

a guest
Oct 22nd, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package red.windrose.blocks;
  2.  
  3. import java.util.Iterator;
  4. import java.util.List;
  5. import java.util.Random;
  6.  
  7. import net.minecraft.block.Block;
  8. import net.minecraft.block.material.Material;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.potion.PotionEffect;
  12. import net.minecraft.util.AxisAlignedBB;
  13. import net.minecraft.world.World;
  14.  
  15. public class MusicBlockBase extends Block{
  16.     public String music_file;
  17.     public MusicBlockBase(Material material, String music) {
  18.         super(material);
  19.         this.setCreativeTab(CreativeTabs.tabDecorations);
  20.         this.music_file = music;
  21.     }
  22.    
  23.     public void onBlockAdded(World world, int x, int y, int z)
  24.     {
  25.         super.onBlockAdded(world, x, y, z);
  26.         world.scheduleBlockUpdate(x, y, z, this, 1);
  27.     }
  28.     public void updateTick(World world, int x, int y, int z, Random rand) {
  29. //      if (world.getTotalWorldTime() % 20L == 0L)
  30. //        {
  31.             setPlayerAudio(world, x, y, z, rand, music_file);
  32. //        }
  33.     }
  34.     private void setPlayerAudio(World world, int x, int y, int z, Random rand, String audio)
  35.     {
  36.         if (!world.isRemote)
  37.         {
  38.             AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)x, (double)y, (double)z, (double)(x + 1), (double)(y + 1), (double)(z + 1)).expand((double)100, (double)100, (double)100);
  39.             axisalignedbb.maxY = (double)world.getHeight();
  40.             List list = world.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
  41.             Iterator iterator = list.iterator();
  42.             System.out.println(list);
  43.             EntityPlayer entityplayer;
  44.            
  45.  
  46.             while (iterator.hasNext())
  47.             {
  48.                 entityplayer = (EntityPlayer)iterator.next();
  49.                System.out.println("I found player " + entityplayer.getDisplayName() + " in my radius");
  50.             }
  51.  
  52.             while(!iterator.hasNext()){
  53.                 System.out.println("There are no players in my radius");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment