Fixed cube bug

This commit is contained in:
alisolarflare 2017-04-02 07:18:10 -04:00
parent 9d138c0b05
commit 7469a6344f
2 changed files with 55 additions and 55 deletions

View file

@ -1,52 +1,52 @@
package buttondevteam.PlaceMinecraft2; package buttondevteam.PlaceMinecraft2;
import org.java_websocket.client.WebSocketClient; import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshake;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
public class PlaceWebSocket extends WebSocketClient { // Ported from https://gist.github.com/teaearlgraycold/76877c8f262de24becc081ad96759730 public class PlaceWebSocket extends WebSocketClient { // Ported from https://gist.github.com/teaearlgraycold/76877c8f262de24becc081ad96759730
public PlaceWebSocket(String wslink) throws URISyntaxException { public PlaceWebSocket(String wslink) throws URISyntaxException {
super(new URI(wslink)); super(new URI(wslink));
/* /*
* insert_queue = 0 inserted_count = 0 max_queue_size = 100 save_frame_per = 20000 * insert_queue = 0 inserted_count = 0 max_queue_size = 100 save_frame_per = 20000
*/ */
} }
@Override @Override
public void onOpen(ServerHandshake handshakedata) { public void onOpen(ServerHandshake handshakedata) {
System.out.println("Status: " + handshakedata.getHttpStatusMessage()); System.out.println("Status: " + handshakedata.getHttpStatusMessage());
} }
@Override @Override
public void onMessage(String message) { public void onMessage(String message) {
JsonObject frame = new JsonParser().parse(message).getAsJsonObject(); JsonObject frame = new JsonParser().parse(message).getAsJsonObject();
String type = frame.get("type").getAsString(); String type = frame.get("type").getAsString();
JsonObject payload = frame.get("payload").getAsJsonObject(); JsonObject payload = frame.get("payload").getAsJsonObject();
System.out.println("Type: " + type); System.out.println("Type: " + type);
if (type.equals("place")) { if (type.equals("place")) {
int x = payload.get("x").getAsInt(); int x = payload.get("x").getAsInt();
int y = payload.get("y").getAsInt(); int y = payload.get("y").getAsInt();
String color = payload.get("color").getAsString(); String color = payload.get("color").getAsString();
String author = payload.get("author").getAsString(); String author = payload.get("author").getAsString();
System.out.println("X: " + x + " - Y: " + y + " - Color: " + color + " - Author: " + author); System.out.println("X: " + x + " - Y: " + y + " - Color: " + color + " - Author: " + author);
} else if (type.equals("activity")) { } else if (type.equals("activity")) {
String count = payload.get("count").getAsString(); String count = payload.get("count").getAsString();
System.out.println("Count: " + count); System.out.println("Count: " + count);
} }
} }
@Override @Override
public void onClose(int code, String reason, boolean remote) { public void onClose(int code, String reason, boolean remote) {
System.out.println("Code: " + code + " - Reason: " + reason + " - Remote: " + remote); System.out.println("Code: " + code + " - Reason: " + reason + " - Remote: " + remote);
} }
@Override @Override
public void onError(Exception ex) { public void onError(Exception ex) {
System.out.println(ex); System.out.println(ex);
} }
} }

View file

@ -18,9 +18,9 @@ public class Writer {
} }
public void writeCube(int x, int y, int z, World world, Material material){ public void writeCube(int x, int y, int z, World world, Material material){
for(int i = 0; i > cubeSize; i++){ for(int i = 0; i < cubeSize; i++){
for (int j = 0; j > cubeSize; j++){ for (int j = 0; j < cubeSize; j++){
for(int k = 0; k > cubeSize; k++){ for(int k = 0; k < cubeSize; k++){
world.getBlockAt(x + i, y + j, z + k).setType(material); world.getBlockAt(x + i, y + j, z + k).setType(material);
} }
} }