From 2b4ba7f8ebdec8e3fdfdf37b204ecce1dc1e7ff3 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Wed, 31 Aug 2016 08:05:56 -0400 Subject: [PATCH] Finished ConflictRTP code --- src/alisolarflare/RandomTP.java | 39 +++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/alisolarflare/RandomTP.java b/src/alisolarflare/RandomTP.java index b2e4fcb..f9c1016 100644 --- a/src/alisolarflare/RandomTP.java +++ b/src/alisolarflare/RandomTP.java @@ -10,7 +10,6 @@ public class RandomTP{ private int conflictX; private int conflictZ; - private int conflictCycle; private int conflictRadius = 70; private boolean northUsed; private boolean southUsed; @@ -63,32 +62,32 @@ public class RandomTP{ } } - int dir = 0; + String dir = "north"; //CHOOSES A RANDOM DIRECTION for(int i = 0; i < 1000; i++){ double randomDirection = Math.random(); if (randomDirection < 0.25){ if(northUsed){ northUsed = true; - dir = 0; + dir = "north"; break; } }else if(randomDirection < 0.50){ if(eastUsed){ eastUsed = true; - dir = 1; + dir = "east"; break; } }else if(randomDirection < 0.75){ if(southUsed){ southUsed = true; - dir = 2; + dir = "south"; break; } }else{ if(westUsed){ westUsed = true; - dir = 3; + dir = "west"; break; } @@ -96,12 +95,28 @@ public class RandomTP{ } - - - - //INCREMENT - shift cycle - conflictCycle++; - //conflict cycle - 0:N, 1:E, 2:S, 3:W + //TELEPORT - teleports player to the conflict point + switch(dir){ + case "north": + northUsed = false; + player.teleport(world.getHighestBlockAt(conflictX, conflictZ - conflictRadius).getLocation()); + break; + case "east": + eastUsed = false; + player.teleport(world.getHighestBlockAt(conflictX + conflictRadius, conflictZ).getLocation()); + break; + case "south": + southUsed = false; + player.teleport(world.getHighestBlockAt(conflictX, conflictZ + conflictRadius).getLocation()); + break; + case "west": + westUsed = false; + player.teleport(world.getHighestBlockAt(conflictX - conflictRadius, conflictZ).getLocation()); + break; + default: + player.teleport(world.getHighestBlockAt(conflictX, conflictZ).getLocation()); + break; + } } //Randomly teleports a player, into the hardcore world