diff --git a/README.md b/README.md
index 4737db3f..87f5bf36 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# RaspberryJuice
A Bukkit plugin which implements the Minecraft Pi Socket API.
+Also supports Nukkit (server for pocket edition clients).
## Commands
@@ -50,11 +51,11 @@ Modify config.yml:
- port: 4711 - the default tcp port can be changed in config.yml
- location: RELATIVE - determine whether locations are RELATIVE to the spawn point (default like pi) or ABSOLUTE
- - hitclick: RIGHT - determine whether hit events are triggered by LEFT clicks, RIGHT clicks or BOTH
+ - hitclick: RIGHT - determine whether hit events are triggered by LEFT clicks, RIGHT clicks or BOTH
## Libraries
-To use the extra features an modded version of the java and python libraries that were originally supplied by Mojang with the Pi is required, [github.com/zhuowei/RaspberryJuice/tree/master/src/main/resources/mcpi](https://github.com/zhuowei/RaspberryJuice/tree/master/src/main/resources/mcpi).
+To use the extra features an modded version of the java and python libraries that were originally supplied by Mojang with the Pi is required, [github.com/zhuowei/RaspberryJuice/tree/master/src/main/resources/mcpi](https://github.com/zhuowei/RaspberryJuice/tree/master/src/main/resources/mcpi).
You only need the modded libraries to use the extra features, the original libraries supplied with Minecraft Pi edition still work, you just wont be able to use the extra features
@@ -68,6 +69,35 @@ cd RaspberryJuice
mvn package
```
+## Pocket edition clients
+
+Mobile clients (also known as Bedrock edition) are supported using [Nukkit]
+server and [Pokkit] plugin that provides interoperability between Nukkit and
+Bukkit.
+
+I made sure the following versions work together: Minecraft PE for Android
+1.12.1, Nukkit server 1.0-SNAPSHOT, Pokkit plugin 0.9 and this RaspberryJuice
+plugin 1.11-pe.
+
+Running the server is easy. First run the server:
+
+ java -jar nukkit-1.0-SNAPSHOT.jar
+
+Then stop it, note the `plugins` directory appeared next to it. Put Pokkit jar
+there and run the server again. Then stop it again and note new directories
+`plugins/Pokkit/bukkitPlugins/` appeared. Put RaspberryJuice jar there and
+eventually run the server again. Connect your mobile client to the server at
+port 19132 by default. To manually check the setup, you may do the following:
+
+ nc localhost 4711
+ player.getTile()
+ 75,-5,-5 <-- your coordinates
+ world.setBlock(75,-6,-5,3) <-- will add a dirt block below you
+ world.spawnEntity(75,-4,-5,93) <-- will spawn a chicken above you
+
+[Nukkit]: https://github.com/NukkitX/Nukkit
+[Pokkit]: https://github.com/PetteriM1/Pokkit
+
## Version history
- 1.11 - spawnEntity, setDirection, setRotation, setPitch
diff --git a/pom.xml b/pom.xml
index fe1282ed..209affe1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0net.zhuoweizhangraspberryjuice
- 1.11
+ 1.11.peRaspberryJuice
@@ -27,8 +27,8 @@
maven-compiler-plugin2.0.2
- 1.6
- 1.6
+ 1.8
+ 1.8
@@ -37,7 +37,7 @@
org.bukkitbukkit
- 1.12.2-R0.1-SNAPSHOT
+ 1.13.2-R0.1-SNAPSHOTprovided
diff --git a/src/main/java/net/zhuoweizhang/raspberryjuice/RaspberryJuicePlugin.java b/src/main/java/net/zhuoweizhang/raspberryjuice/RaspberryJuicePlugin.java
index 4b855bdb..f2f19007 100644
--- a/src/main/java/net/zhuoweizhang/raspberryjuice/RaspberryJuicePlugin.java
+++ b/src/main/java/net/zhuoweizhang/raspberryjuice/RaspberryJuicePlugin.java
@@ -18,10 +18,10 @@ public class RaspberryJuicePlugin extends JavaPlugin implements Listener {
public static final Set blockBreakDetectionTools = EnumSet.of(
Material.DIAMOND_SWORD,
- Material.GOLD_SWORD,
+ Material.LEGACY_GOLD_SWORD,
Material.IRON_SWORD,
Material.STONE_SWORD,
- Material.WOOD_SWORD);
+ Material.LEGACY_WOOD_SWORD);
public ServerListenerThread serverThread;
diff --git a/src/main/java/net/zhuoweizhang/raspberryjuice/RemoteSession.java b/src/main/java/net/zhuoweizhang/raspberryjuice/RemoteSession.java
index 5c0acbbe..64998ea5 100644
--- a/src/main/java/net/zhuoweizhang/raspberryjuice/RemoteSession.java
+++ b/src/main/java/net/zhuoweizhang/raspberryjuice/RemoteSession.java
@@ -37,6 +37,8 @@ public class RemoteSession {
public RaspberryJuicePlugin plugin;
+ public Map materialById;
+
protected ArrayDeque interactEventQueue = new ArrayDeque();
protected ArrayDeque chatPostedQueue = new ArrayDeque();
@@ -60,6 +62,10 @@ public void init() throws IOException {
socket.setTrafficClass(0x10);
this.in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
this.out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
+ this.materialById = new HashMap();
+ for (Material m : Material.values()) {
+ this.materialById.put(m.getId(), m);
+ }
startThreads();
plugin.getLogger().info("Opened connection to" + socket.getRemoteSocketAddress() + ".");
}
@@ -146,7 +152,7 @@ protected void handleCommand(String c, String[] args) {
// world.getBlock
if (c.equals("world.getBlock")) {
Location loc = parseRelativeBlockLocation(args[0], args[1], args[2]);
- send(world.getBlockTypeIdAt(loc));
+ send(world.getBlockAt(loc).getType().getId());
// world.getBlocks
} else if (c.equals("world.getBlocks")) {
@@ -157,7 +163,8 @@ protected void handleCommand(String c, String[] args) {
// world.getBlockWithData
} else if (c.equals("world.getBlockWithData")) {
Location loc = parseRelativeBlockLocation(args[0], args[1], args[2]);
- send(world.getBlockTypeIdAt(loc) + "," + world.getBlockAt(loc).getData());
+ Block block = world.getBlockAt(loc);
+ send(block.getType().getId() + "," + block.getData());
// world.setBlock
} else if (c.equals("world.setBlock")) {
@@ -478,8 +485,8 @@ protected void handleCommand(String c, String[] args) {
//facing direction for wall sign : 2=north, 3=south, 4=west, 5=east
//rotation 0 - to 15 for standing sign : 0=south, 4=west, 8=north, 12=east
byte blockData = Byte.parseByte(args[4]);
- if ((thisBlock.getTypeId() != blockType) || (thisBlock.getData() != blockData)) {
- thisBlock.setTypeIdAndData(blockType, blockData, true);
+ if ((thisBlock.getType().getId() != blockType) || (thisBlock.getData() != blockData)) {
+ updateBlock(thisBlock, blockType, blockData);
}
//plugin.getLogger().info("Creating sign at " + loc);
if ( thisBlock.getState() instanceof Sign ) {
@@ -559,7 +566,7 @@ private String getBlocks(Location pos1, Location pos2) {
for (int y = minY; y <= maxY; ++y) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
- blockData.append(new Integer(world.getBlockTypeIdAt(x, y, z)).toString() + ",");
+ blockData.append(new Integer(world.getBlockAt(x, y, z).getType().getId()).toString() + ",");
}
}
}
@@ -579,9 +586,16 @@ private void updateBlock(World world, int x, int y, int z, int blockType, byte b
}
private void updateBlock(Block thisBlock, int blockType, byte blockData) {
+ if (blockData != 0) {
+ plugin.getLogger().warning(
+ "Block data byte (" + blockData + ") " +
+ "is no longer supported by API, ignored. " +
+ "Use materials instead.");
+ }
// check to see if the block is different - otherwise leave it
- if ((thisBlock.getTypeId() != blockType) || (thisBlock.getData() != blockData)) {
- thisBlock.setTypeIdAndData(blockType, blockData, true);
+ if (thisBlock.getType().getId() != blockType) {
+ Material material = this.materialById.get(blockType);
+ thisBlock.setType(material, true);
}
}