Advertisement
Corosus

Wugs portal/dimension code

Nov 29th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.08 KB | None | 0 0
  1. // Wug's usePortal ==
  2.  
  3.     public void usePortal(int i)
  4.     {
  5.         int j = thePlayer.dimension;
  6.         thePlayer.dimension = i;
  7.         theWorld.setEntityDead(thePlayer);
  8.         thePlayer.isDead = false;
  9.         WorldProvider newWorldProvider = WugApi.getProviderForDimension(thePlayer.dimension);
  10.         WorldProvider oldWorldProvider = WugApi.getProviderForDimension(j);
  11.        
  12.         Position oldpos = new Position(thePlayer);
  13.         Position newpos = newWorldProvider.getEntryPoint(oldWorldProvider.getExitPoint(oldpos));
  14.        
  15.         if (!newWorldProvider.canRespawnHere() || thePlayer.isEntityAlive())
  16.             thePlayer.setLocationAndAngles(newpos.x, newpos.y, newpos.z, thePlayer.rotationYaw, thePlayer.rotationPitch);
  17.         if (thePlayer.isEntityAlive())
  18.             theWorld.updateEntityWithOptionalForce(thePlayer, false);
  19.         changeWorld(new World(theWorld, newWorldProvider), newWorldProvider.travelMsg(j), thePlayer);
  20.        
  21.         thePlayer.worldObj = theWorld;
  22.         System.out.println((new StringBuilder()).append("Teleported to ").append(theWorld.worldProvider.worldType).toString());
  23.        
  24.         newWorldProvider.relocate(theWorld, thePlayer, oldWorldProvider);
  25.     }
  26.  
  27. // Notch's usePortal ==
  28.  
  29.     public void usePortal(int i)
  30.     {
  31.         int j = thePlayer.dimension;
  32.         thePlayer.dimension = i;
  33.         theWorld.setEntityDead(thePlayer);
  34.         thePlayer.isDead = false;
  35.         double d = thePlayer.posX;
  36.         double d1 = thePlayer.posZ;
  37.         double d2 = 1.0D;
  38.         if(j > -1 && thePlayer.dimension == -1)
  39.         {
  40.             d2 = 0.125D;
  41.         } else
  42.         if(j == -1 && thePlayer.dimension > -1)
  43.         {
  44.             d2 = 8D;
  45.         }
  46.         d *= d2;
  47.         d1 *= d2;
  48.         if(thePlayer.dimension == -1)
  49.         {
  50.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  51.             if(thePlayer.isEntityAlive())
  52.             {
  53.                 theWorld.updateEntityWithOptionalForce(thePlayer, false);
  54.             }
  55.             World world = null;
  56.             world = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
  57.             changeWorld(world, "Entering the Nether", thePlayer);
  58.         } else
  59.         if(thePlayer.dimension == 0)
  60.         {
  61.             if(thePlayer.isEntityAlive())
  62.             {
  63.                 thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  64.                 theWorld.updateEntityWithOptionalForce(thePlayer, false);
  65.             }
  66.             World world1 = null;
  67.             world1 = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
  68.             if(j == -1)
  69.             {
  70.                 changeWorld(world1, "Leaving the Nether", thePlayer);
  71.             } else
  72.             {
  73.                 changeWorld(world1, "Leaving the End", thePlayer);
  74.             }
  75.         } else
  76.         {
  77.             World world2 = null;
  78.             world2 = new World(theWorld, WorldProvider.getProviderForDimension(thePlayer.dimension));
  79.             ChunkCoordinates chunkcoordinates = world2.func_40472_j();
  80.             d = chunkcoordinates.posX;
  81.             thePlayer.posY = chunkcoordinates.posY;
  82.             d1 = chunkcoordinates.posZ;
  83.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, 90F, 0.0F);
  84.             if(thePlayer.isEntityAlive())
  85.             {
  86.                 world2.updateEntityWithOptionalForce(thePlayer, false);
  87.             }
  88.             changeWorld(world2, "Entering the End", thePlayer);
  89.         }
  90.         thePlayer.worldObj = theWorld;
  91.         System.out.println((new StringBuilder()).append("Teleported to ").append(theWorld.worldProvider.worldType).toString());
  92.         if(thePlayer.isEntityAlive() && j < 1)
  93.         {
  94.             thePlayer.setLocationAndAngles(d, thePlayer.posY, d1, thePlayer.rotationYaw, thePlayer.rotationPitch);
  95.             theWorld.updateEntityWithOptionalForce(thePlayer, false);
  96.             (new Teleporter()).placeInPortal(theWorld, thePlayer);
  97.         }
  98.     }
  99.  
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement