Skip to content

Instantly share code, notes, and snippets.

@jroweboy
Created April 29, 2014 00:55
Show Gist options
  • Save jroweboy/11388243 to your computer and use it in GitHub Desktop.
Save jroweboy/11388243 to your computer and use it in GitHub Desktop.
A very simple to create a world border in minecraft 1.8 (until the world border command works right)
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
/**
*
* @author b0b & Kilvean
*/
public class BattleMode {
public static Robot robot;
public static void main(String[] args) throws AWTException, InterruptedException {
robot = new java.awt.Robot();
BattleMode.sleep(5000);
final int width = 200;
final int start_x = -169;
// final int start_y = ;
final int start_z = 223;
for (int i=0; i<10; ++i){
BattleMode.type("/fill " +(start_x-100)+ " 1 " +(start_z-100+i*20)+ " " +(start_x-100)+ " 200 " +(start_z-100+(i+1)*20-1)+ " barrier");
BattleMode.sleep(100);
BattleMode.type("/fill " +(start_x-100+i*20)+ " 1 " +(start_z+100)+ " " +(start_x-100+(i+1)*20-1)+ " 200 " +(start_z+100)+ " barrier");
BattleMode.sleep(100);
BattleMode.type("/fill " +(start_x+100)+ " 1 " +(start_z-100+i*20)+ " " +(start_x+100)+ " 200 " +(start_z-100+(i+1)*20-1)+ " barrier");
BattleMode.sleep(100);
BattleMode.type("/fill " +(start_x-100+i*20)+ " 1 " +(start_z-100)+ " " +(start_x-100+(i+1)*20-1)+ " 200 " +(start_z-100)+ " barrier");
BattleMode.sleep(100);
// BattleMode.type("/fill " +(start_x-100+i*20)+ " 200 " +(start_z-100)+ " " +(start_x-100+(i+1)*20-1)+ " 200 " +(start_z+100)+ " barrier");
// BattleMode.sleep(1000);
}
}
public static void sleep(long seconds) throws InterruptedException {
Thread.sleep(seconds);
}
public static void type(String characters) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection( characters );
clipboard.setContents(stringSelection, null);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
/**
* Debug functions. Rename the other function to type1 and sleep1 and these to type and sleep
*/
public static int counter = 0;
public static void type1(String c){
System.out.println((counter++) + ": " +c);
}
public static void sleep1(long seconds){
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment