Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.21 KB | None | 0 0
  1. package com.mrzorse.startrek.packets;
  2.  
  3. import com.mrzorse.startrek.StarTrek;
  4. import com.mrzorse.startrek.api.weaponeffects.SimpleEffects;
  5. import com.mrzorse.startrek.blocks.BlockIngotFurnace;
  6. import com.mrzorse.startrek.blocks.BlockTransporterInterlock;
  7. import com.mrzorse.startrek.tileentity.tileentities.TileEntityTransportInterlock;
  8.  
  9. import net.minecraft.block.Block;
  10. import net.minecraft.client.Minecraft;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.nbt.NBTTagCompound;
  13. import net.minecraft.server.MinecraftServer;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.util.MathHelper;
  16. import net.minecraft.world.World;
  17. import cpw.mods.fml.common.network.simpleimpl.IMessage;
  18. import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
  19. import cpw.mods.fml.common.network.simpleimpl.MessageContext;
  20.  
  21. public class TeleporterHandler implements IMessageHandler<TransporterPacket, IMessage> {
  22.     private String bp;
  23.    
  24.     @Override
  25.     public IMessage onMessage(TransporterPacket message, MessageContext ctx) {
  26.    
  27.         String command = message.text.toString();
  28.         String[] finalcommand = command.split(" ");
  29.         String playerName = finalcommand[1].toString();
  30.        
  31.        
  32.         EntityPlayer playertp = ctx.getServerHandler().playerEntity.worldObj.getPlayerEntityByName(playerName);
  33.         World world = ctx.getServerHandler().playerEntity.worldObj;
  34.        
  35.         if(finalcommand[0].equalsIgnoreCase("bts")){
  36.             //command is: {{{ bts MrZorse betastation
  37.             String tilexs2 = finalcommand[3];
  38.             String tileys2 = finalcommand[4];
  39.             String tilezs2 = finalcommand[5];
  40.             int tilex2 = Integer.valueOf(tilexs2);
  41.             int tiley2 = Integer.valueOf(tileys2);
  42.             int tilez2 = Integer.valueOf(tilezs2);
  43.             int r = 120;
  44.            
  45.             boolean finished = false;
  46.            
  47.             for(int x1 = -r; x1 < r && !finished; x1++){
  48.                 for(int y1 = -r; y1 < r && !finished; y1++){
  49.                         for(int z1 = -r; z1 < r; z1++){                                    
  50.                                 double dist = MathHelper.sqrt_double((x1*x1 + y1*y1 + z1*z1)); //Calculates the distance
  51.                                 if(dist > r)
  52.                                        
  53.                                         continue;
  54.                                        
  55.  
  56.                                 Block blockatcords = world.getBlock(tilex2+x1, tiley2+y1, tilez2+z1);
  57.                                 if(blockatcords==StarTrek.blockTransporterInterlock){
  58.                                     int blocktilex = tilex2 + x1;
  59.                                     int blocktiley = tiley2 + y1;
  60.                                     int blocktilez = tilez2+ z1;
  61.                                
  62.                                     TileEntityTransportInterlock tinterlock = (TileEntityTransportInterlock) world.getTileEntity(blocktilex, blocktiley, blocktilez);
  63.                                    
  64.                                     System.out.println(tinterlock.id);
  65.                                
  66.                                     x1=r;
  67.                                     y1=r;
  68.                                     z1=r;
  69.                                
  70.                                
  71.                                    
  72.                                 }
  73.                         }
  74.                 }
  75.             }
  76.         }
  77.          
  78.        
  79.    
  80.         return null;
  81.     }
  82.    
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement