diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3b2d3a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/.gradle +/.classpath +/.project +/.settings +/bin/ +/build/ +/python-scripts.zip +/.pydevproject diff --git a/110/.gitignore b/110/.gitignore new file mode 100644 index 0000000..2fbd8a0 --- /dev/null +++ b/110/.gitignore @@ -0,0 +1,7 @@ +/.gradle/ +/build/ +/src/ +/bin/ +/.classpath +/.settings/ +/.project \ No newline at end of file diff --git a/110/build.gradle b/110/build.gradle index f0aa8c5..28fc00e 100644 --- a/110/build.gradle +++ b/110/build.gradle @@ -24,8 +24,14 @@ version = "0.94" group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RaspberryJamMod" +sourceCompatibility = targetCompatibility = "1.7" // Need this here so eclipse task generates correctly. +//compileJava.options.bootClasspath = "$JDK7_HOME/jre/lib/rt.jar" +compileJava { + sourceCompatibility = targetCompatibility = "1.7" +} + minecraft { - version = "1.10.2-12.18.2.2147" + version = "1.10.2-12.18.3.2511" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -33,7 +39,7 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "snapshot_20161116" + mappings = "snapshot_20161111" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/110/fast.sh b/110/fast.sh index 3a37387..444f615 100644 --- a/110/fast.sh +++ b/110/fast.sh @@ -17,9 +17,9 @@ cp build/libs/RaspberryJamMod.jar ../build/out/1.10/ cp build/libs/RaspberryJamMod.jar ../build/out/1.10.2/ if [ "$1" != "noinstall" ] then - mkdir $APPDATA/.minecraft/mods - mkdir $APPDATA/.minecraft/mods/1.10 - mkdir $APPDATA/.minecraft/mods/1.10.2 + mkdir $APPDATA/.minecraft/mods 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.10 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.10.2 2> /dev/null cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.10/ cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.10.2/ else diff --git a/110/fix.sed b/110/fix.sed index da08d89..416f8ed 100644 --- a/110/fix.sed +++ b/110/fix.sed @@ -1,8 +1,6 @@ s/Blocks\.air/Blocks.AIR/g s/MobEffects\.levitation/MobEffects.LEVITATION/g s/MobEffects\.nightVision/MobEffects.NIGHT_VISION/g -s/\.thePlayer/\.player/g -s/\.theWorld/\.world/g s/\[1\.9,1\.9\.4)/[1.9.4,1.11)/ s/getUnformattedTextForChat/getUnformattedComponentText/g s/NOMINAL_VERSION\s*=\s*1009000/NOMINAL_VERSION = 1010000/ diff --git a/110/gradle.properties b/110/gradle.properties new file mode 100644 index 0000000..4bfa288 --- /dev/null +++ b/110/gradle.properties @@ -0,0 +1 @@ +JDK7_HOME=c:/Program Files/Java/jdk1.7.0_80 \ No newline at end of file diff --git a/111/.gitignore b/111/.gitignore new file mode 100644 index 0000000..c6d4ab6 --- /dev/null +++ b/111/.gitignore @@ -0,0 +1,7 @@ +/.gradle/ +/build/ +/src/ +/bin/ +/.classpath +/.project +/.settings/ \ No newline at end of file diff --git a/111/build.gradle b/111/build.gradle index 40943d9..a4c9609 100644 --- a/111/build.gradle +++ b/111/build.gradle @@ -24,8 +24,14 @@ version = "0.94" group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RaspberryJamMod" +sourceCompatibility = targetCompatibility = "1.7" // Need this here so eclipse task generates correctly. +//compileJava.options.bootClasspath = "$JDK7_HOME/jre/lib/rt.jar" +compileJava { + sourceCompatibility = targetCompatibility = "1.7" +} + minecraft { - version = "2151" + version = "1.11-13.19.1.2199" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -33,8 +39,7 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. - //mappings = "snapshot_20161124" - mappings = "snapshot_20161208" + mappings = "snapshot_20161220" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/111/fast.sh b/111/fast.sh index 15e3e8a..3debd47 100644 --- a/111/fast.sh +++ b/111/fast.sh @@ -17,9 +17,9 @@ cp build/libs/RaspberryJamMod.jar ../build/out/1.11/ cp build/libs/RaspberryJamMod.jar ../build/out/1.11.2/ if [ "$1" != "noinstall" ] then - mkdir $APPDATA/.minecraft/mods - mkdir $APPDATA/.minecraft/mods/1.11 - mkdir $APPDATA/.minecraft/mods/1.11.2 + mkdir $APPDATA/.minecraft/mods 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.11 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.11.2 2> /dev/null cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.11/ cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.11.2/ else diff --git a/111/fix.sed b/111/fix.sed index d3837f8..3d9312d 100644 --- a/111/fix.sed +++ b/111/fix.sed @@ -15,4 +15,6 @@ s/spawnEntityInWorld/spawnEntity/g s/createEntityByName/createEntityByIDFromName/g s/worldServers/worlds/g s/getUnformattedTextForChat/getUnformattedComponentText/g -s/getPlayerList()\.getPlayerList()/getPlayerList().getPlayers()/g \ No newline at end of file +s/getPlayerList()\.getPlayerList()/getPlayerList().getPlayers()/g +s/getEntityID(e/getID(e.getClass()/g +s/for (String entityTypeName : EntityList.getEntityNameList()) { if (EntityList.getIDFromString(entityTypeName) >= 0) { bdr.append(EntityList.getIDFromString(entityTypeName)); bdr.append(","); bdr.append(entityTypeName); bdr.append("|"); }/for (ResourceLocation rl: EntityList.getEntityNameList()) { if (EntityList.getClass(rl) != null) { bdr.append(EntityList.getID(EntityList.getClass(rl))); bdr.append(","); bdr.append(rl.getResourcePath()); bdr.append("|"); }/g diff --git a/111/gradle.properties b/111/gradle.properties new file mode 100644 index 0000000..4bfa288 --- /dev/null +++ b/111/gradle.properties @@ -0,0 +1 @@ +JDK7_HOME=c:/Program Files/Java/jdk1.7.0_80 \ No newline at end of file diff --git a/112/.gitignore b/112/.gitignore new file mode 100644 index 0000000..c6d4ab6 --- /dev/null +++ b/112/.gitignore @@ -0,0 +1,7 @@ +/.gradle/ +/build/ +/src/ +/bin/ +/.classpath +/.project +/.settings/ \ No newline at end of file diff --git a/112/build.gradle b/112/build.gradle index 19a35a7..2235624 100644 --- a/112/build.gradle +++ b/112/build.gradle @@ -9,7 +9,7 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle.forge' @@ -24,8 +24,14 @@ version = "0.94" group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RaspberryJamMod" +sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. +//compileJava.options.bootClasspath = "$JDK8_HOME/jre/lib/rt.jar" +compileJava { + sourceCompatibility = targetCompatibility = '1.8' +} + minecraft { - version = "2151" + version = "1.12-14.21.1.2443" runDir = "run" // the mappings can be changed at any time, and must be in the following format. @@ -33,8 +39,7 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. - //mappings = "snapshot_20161124" - mappings = "snapshot_20170613" + mappings = "snapshot_20170624" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/112/fast.sh b/112/fast.sh index 40b0b08..ebc905a 100644 --- a/112/fast.sh +++ b/112/fast.sh @@ -6,19 +6,23 @@ for x in src/main/java/mobi/omegacentauri/raspberryjammod/*.java ; do sed -i -f fix.sed $x done rm build/libs/Raspberr*.jar 2> /dev/null -sh gradlew --offline build +sh gradlew build # --offline build rm build/libs/Raspberry*ources.jar 2> /dev/null mv build/libs/Raspberr* build/libs/RaspberryJamMod.jar 2> /dev/null mkdir ../build/out 2> /dev/null mkdir ../build/out/1.12 2> /dev/null +mkdir ../build/out/1.12.1 2> /dev/null +mkdir ../build/out/1.12.2 2> /dev/null cp build/libs/RaspberryJamMod.jar ../build/out/1.12/ +cp build/libs/RaspberryJamMod.jar ../build/out/1.12.1/ +cp build/libs/RaspberryJamMod.jar ../build/out/1.12.2/ if [ "$1" != "noinstall" ] then - mkdir $APPDATA/.minecraft/mods - mkdir $APPDATA/.minecraft/mods/1.12 - mkdir $APPDATA/.minecraft/mods/1.12.1 - mkdir $APPDATA/.minecraft/mods/1.12.2 + mkdir $APPDATA/.minecraft/mods 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.12 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.12.1 2> /dev/null + mkdir $APPDATA/.minecraft/mods/1.12.2 2> /dev/null cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.12/ cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.12.1/ cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/1.12.2/ diff --git a/112/fix.sed b/112/fix.sed index cab3a13..4cc5cae 100644 --- a/112/fix.sed +++ b/112/fix.sed @@ -20,3 +20,8 @@ s/\.xCoord/.x/g s/\.yCoord/.y/g s/\.zCoord/.z/g s/worldServerForDimension/getWorld/g +s/getEntityID(e/getID(e.getClass()/g +s/import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;//g +s/@Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {return null;}//g +s/@Override public Class mainConfigGuiClass() {return Gui.class;}//g +s/for (String entityTypeName : EntityList.getEntityNameList()) { if (EntityList.getIDFromString(entityTypeName) >= 0) { bdr.append(EntityList.getIDFromString(entityTypeName)); bdr.append(","); bdr.append(entityTypeName); bdr.append("|"); }/for (ResourceLocation rl: EntityList.getEntityNameList()) { if (EntityList.getClass(rl) != null) { bdr.append(EntityList.getID(EntityList.getClass(rl))); bdr.append(","); bdr.append(rl.getResourcePath()); bdr.append("|"); }/g diff --git a/112/gradle.properties b/112/gradle.properties new file mode 100644 index 0000000..975a97e --- /dev/null +++ b/112/gradle.properties @@ -0,0 +1 @@ +JDK8_HOME=c:/Program Files/Java/jdk1.8.0_202 \ No newline at end of file diff --git a/19/.gitignore b/19/.gitignore new file mode 100644 index 0000000..856db23 --- /dev/null +++ b/19/.gitignore @@ -0,0 +1,6 @@ +/.gradle/ +/.classpath +/.project +/.settings/ +/bin/ +/build/ diff --git a/19/build.gradle b/19/build.gradle index 9dc554b..2908908 100644 --- a/19/build.gradle +++ b/19/build.gradle @@ -24,6 +24,12 @@ version = "0.94" group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RaspberryJamMod" +sourceCompatibility = targetCompatibility = "1.7" // Need this here so eclipse task generates correctly. +//compileJava.options.bootClasspath = "$JDK7_HOME/jre/lib/rt.jar" +compileJava { + sourceCompatibility = targetCompatibility = "1.7" +} + minecraft { version = "1.9-12.16.0.1864-1.9" runDir = "run" diff --git a/19/gradle.properties b/19/gradle.properties new file mode 100644 index 0000000..4bfa288 --- /dev/null +++ b/19/gradle.properties @@ -0,0 +1 @@ +JDK7_HOME=c:/Program Files/Java/jdk1.7.0_80 \ No newline at end of file diff --git a/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java b/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java index 918e0d7..d7f66d8 100644 --- a/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java +++ b/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java @@ -48,6 +48,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; @@ -75,6 +76,9 @@ public class APIHandler { protected static final String GETBLOCKSWITHDATA = "world.getBlocksWithData"; protected static final String GETHEIGHT = "world.getHeight"; protected static final String WORLDSPAWNENTITY = "world.spawnEntity"; + protected static final String WORLDGETENTITYTYPES = "world.getEntityTypes"; + protected static final String WORLDGETENTITIES = "world.getEntities"; + protected static final String WORLDREMOVEENTITYTYPE = "world.removeEntityType"; protected static final String WORLDSPAWNPARTICLE = "world.spawnParticle"; protected static final String WORLDDELETEENTITY = "world.removeEntity"; protected static final String WORLDGETPLAYERIDS = "world.getPlayerIds"; @@ -122,6 +126,8 @@ public class APIHandler { protected static final String SETROTATION = "setRotation"; protected static final String SETTILE = "setTile"; protected static final String CHAT = "chat.post"; + protected static final String GETENTITIES = "getEntities"; + protected static final String REMOVEENTITYTYPE = "removeEntityType"; protected String[] fullCommands = { CHATGLOBAL, @@ -136,6 +142,9 @@ public class APIHandler { GETBLOCKSWITHDATA, GETHEIGHT, WORLDSPAWNENTITY, + WORLDGETENTITYTYPES, + WORLDGETENTITIES, + WORLDREMOVEENTITYTYPE, WORLDSPAWNPARTICLE, WORLDDELETEENTITY, WORLDGETPLAYERIDS, @@ -182,7 +191,9 @@ public class APIHandler { SETDIMENSION, SETPITCH, SETROTATION, - CHAT + CHAT, + GETENTITIES, + REMOVEENTITYTYPE }; protected static final String[][] ENTITY_RENAME_111 = { @@ -780,6 +791,15 @@ else if (cmd.equals(WORLDDELETEENTITY)) { else if (cmd.equals(WORLDSPAWNENTITY)) { spawnEntity(scan); } + else if (cmd.equals(WORLDGETENTITYTYPES)) { + getEntityTypes(scan); + } + else if (cmd.equals(WORLDGETENTITIES)) { + getEntities(scan); + } + else if (cmd.equals(WORLDREMOVEENTITYTYPE)) { + removeEntityType(scan); + } else if (cmd.equals(WORLDSPAWNPARTICLE)) { spawnParticle(scan); } @@ -920,8 +940,45 @@ protected String rename111(String entityId) { } protected void spawnEntity(Scanner scan) { + // detect RaspberryJamMod (type,x,y,z,tags) or RaspberryJuice (x,y,z,id) syntax + if (scan.hasNextDouble()) + spawnEntityJuice(scan); + else + spawnEntityJam(scan); + } + + protected void spawnEntityJuice(Scanner scan) { + double x0 = scan.nextDouble(); + double y0 = scan.nextDouble(); + double z0 = scan.nextDouble(); + Vec3w pos = Location.decodeVec3w(serverWorlds, x0, y0, z0); + + int entityID = scan.nextInt(); + + // TODO? Could do damage by spawning dragons close to a forbidden zone; perhaps forbid that? + if (permission != null && ! permission.isPermitted(pos.world, + (int)Math.floor(pos.xCoord),(int)Math.floor(pos.zCoord))) + return; + + Entity entity; + try { + entity = EntityList.createEntityByID(entityID, pos.world); + if (entity == null) { + throw new Exception(); + } + } catch(Exception e) { + fail("Cannot create entity"); + return; + } + + entity.setPositionAndUpdate(pos.xCoord, pos.yCoord, pos.zCoord); + pos.world.spawnEntityInWorld(entity); + sendLine(entity.getEntityId()); + } + + protected void spawnEntityJam(Scanner scan) { String entityId = scan.next(); - + System.out.println("Helo"); if (RaspberryJamMod.NOMINAL_VERSION >= 1011000) { System.out.println("ren"); @@ -978,6 +1035,52 @@ protected void spawnEntity(Scanner scan) { //TODO: antigravity for NoAI:1 } + protected void getEntityTypes(Scanner scan) { + + StringBuilder bdr = new StringBuilder(); + + for (String entityTypeName : EntityList.getEntityNameList()) { if (EntityList.getIDFromString(entityTypeName) >= 0) { bdr.append(EntityList.getIDFromString(entityTypeName)); bdr.append(","); bdr.append(entityTypeName); bdr.append("|"); } + //MC 1.11 and 1.12 replacement: for (ResourceLocation rl: EntityList.getEntityNameList()) { if (EntityList.getClass(rl) != null) { bdr.append(EntityList.getID(EntityList.getClass(rl))); bdr.append(","); bdr.append(rl.getResourcePath()); bdr.append("|"); } +} + sendLine(bdr.toString()); + } + + protected void getEntities(Scanner scan) { + + StringBuilder bdr = new StringBuilder(); + for (Entity e : serverWorlds[0].loadedEntityList) { + if (EntityList.getEntityID(e) >= 0) + { + bdr.append(e.getEntityId()); + bdr.append(","); + bdr.append(EntityList.getEntityID(e)); + bdr.append(","); + bdr.append(EntityList.getEntityString(e)); + bdr.append(","); + bdr.append(e.getPositionVector().xCoord); + bdr.append(","); + bdr.append(e.getPositionVector().yCoord); + bdr.append(","); + bdr.append(e.getPositionVector().zCoord); + bdr.append("|"); + } + } + sendLine(bdr.toString()); + } + + protected void removeEntityType(Scanner scan) { + int entityTypeId = scan.nextInt(); + int removedEntitiesCount = 0; + for (Entity e : serverWorlds[0].loadedEntityList) { + if (EntityList.getEntityID(e) == entityTypeId) + { + serverWorlds[0].removeEntity(e); + removedEntitiesCount++; + } + } + sendLine(removedEntitiesCount); + } + protected void chat(int id, String msg) { Entity e = getServerEntityByID(id); if (e == null || ! (e instanceof EntityPlayer)) { @@ -1154,6 +1257,12 @@ else if (cmd.equals(GETNAMEUUID)) { } else if (cmd.equals(CHAT)) { chat(id, scan.next()); + } + else if (cmd.equals(GETENTITIES)) { + entityGetEntities(id, scan); + } + else if (cmd.equals(REMOVEENTITYTYPE)) { + entityRemoveEntityType(id, scan); } else { unknownCommand(); @@ -1187,6 +1296,54 @@ protected void entitySetDirection(int id, Scanner scan) { entitySetDirection(e, x, y, z); } + protected void entityGetEntities(int id, Scanner scan) { + int distance = 10; + if (scan.hasNextInt()) + distance = scan.nextInt(); + Entity playerEntityId = getServerEntityByID(id); + + StringBuilder bdr = new StringBuilder(); + for (Entity e : serverWorlds[0].loadedEntityList) { + if (EntityList.getEntityID(e) >= 0 && getDistance(playerEntityId, e) <= distance) + { + bdr.append(e.getEntityId()); + bdr.append(","); + bdr.append(EntityList.getEntityID(e)); + bdr.append(","); + bdr.append(EntityList.getEntityString(e)); + bdr.append(","); + bdr.append(e.getPositionVector().xCoord); + bdr.append(","); + bdr.append(e.getPositionVector().yCoord); + bdr.append(","); + bdr.append(e.getPositionVector().zCoord); + bdr.append("|"); + } + } + sendLine(bdr.toString()); + } + + protected void entityRemoveEntityType(int id, Scanner scan) { + int entityTypeId = scan.nextInt(); + int removedEntitiesCount = 0; + int distance = 10; + if (scan.hasNextInt()) + distance = scan.nextInt(); + Entity playerEntityId = getServerEntityByID(id); + + for (Entity e : serverWorlds[0].loadedEntityList) { + if (EntityList.getEntityID(e) >= 0 && getDistance(playerEntityId, e) <= distance) + { + if (EntityList.getEntityID(e) == entityTypeId) + { + serverWorlds[0].removeEntity(e); + removedEntitiesCount++; + } + } + } + sendLine(removedEntitiesCount); + } + static protected String getRest(Scanner scan) { StringBuilder out = new StringBuilder(); @@ -1609,4 +1766,13 @@ public String getDescription() { return description; } } + + private int getDistance(Entity ent1, Entity ent2) { + if (ent1 == null || ent2 == null) + return -1; + double dx = ent2.getPositionVector().xCoord - ent1.getPositionVector().xCoord; + double dy = ent2.getPositionVector().yCoord - ent1.getPositionVector().yCoord; + double dz = ent2.getPositionVector().zCoord - ent1.getPositionVector().zCoord; + return (int)Math.sqrt(dx*dx + dy*dy + dz*dz); + } } diff --git a/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIServer.java b/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIServer.java index 80bda44..244a179 100644 --- a/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIServer.java +++ b/19/src/main/java/mobi/omegacentauri/raspberryjammod/APIServer.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.lang.reflect.Method; import java.net.InetAddress; @@ -136,8 +137,8 @@ private void socketCommunicate(Socket connectionSocket) { try { String clientSentence; - reader = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); - writer = new PrintWriter(connectionSocket.getOutputStream()); + reader = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream(), "UTF-8")); + writer = new PrintWriter(new OutputStreamWriter(connectionSocket.getOutputStream(), "UTF-8")); api = controlServer ? new APIHandler(eventHandler, writer) : new APIHandlerClientOnly(eventHandler, writer); diff --git a/19/src/main/java/mobi/omegacentauri/raspberryjammod/GuiFactory.java b/19/src/main/java/mobi/omegacentauri/raspberryjammod/GuiFactory.java index 7fc2e9e..b60e331 100644 --- a/19/src/main/java/mobi/omegacentauri/raspberryjammod/GuiFactory.java +++ b/19/src/main/java/mobi/omegacentauri/raspberryjammod/GuiFactory.java @@ -12,21 +12,14 @@ public class GuiFactory implements IModGuiFactory { public void initialize(Minecraft minecraftInstance) { } - @Override - public Class mainConfigGuiClass() { - return Gui.class; - } + @Override public Class mainConfigGuiClass() {return Gui.class;} @Override public Set runtimeGuiCategories() { return null; } - @Override - public RuntimeOptionGuiHandler getHandlerFor( - RuntimeOptionCategoryElement element) { - return null; - } + @Override public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {return null;} public boolean hasConfigGui() { return true; diff --git a/194/.gitignore b/194/.gitignore new file mode 100644 index 0000000..a247e62 --- /dev/null +++ b/194/.gitignore @@ -0,0 +1,3 @@ +/.gradle/ +/build/ +/src/ diff --git a/194/build.gradle b/194/build.gradle index 2f632d3..011d789 100644 --- a/194/build.gradle +++ b/194/build.gradle @@ -24,6 +24,12 @@ version = "0.94" group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "RaspberryJamMod" +sourceCompatibility = targetCompatibility = "1.7" // Need this here so eclipse task generates correctly. +//compileJava.options.bootClasspath = "$JDK7_HOME/jre/lib/rt.jar" +compileJava { + sourceCompatibility = targetCompatibility = "1.7" +} + minecraft { version = "1.9.4-12.17.0.1964" runDir = "run" diff --git a/194/gradle.properties b/194/gradle.properties new file mode 100644 index 0000000..4bfa288 --- /dev/null +++ b/194/gradle.properties @@ -0,0 +1 @@ +JDK7_HOME=c:/Program Files/Java/jdk1.7.0_80 \ No newline at end of file diff --git a/BUILDING.md b/BUILDING.md index 93cae73..bf94c0b 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -23,6 +23,8 @@ root directory : version for Minecraft 1.8x 19 : version for Minecraft 1.9 194 : version for Minecraft 1.9.4 110 : version for Minecraft 1.10 +111 : version for Minecraft 1.11 +112 : version for Minecraft 1.12 The 194 and 110 versions do not contain source code. Instead, running fast.sh in those directories copies the source tree from the 19 directory, patches it up as needed, and diff --git a/RaspberryJamMod.iss b/RaspberryJamMod.iss index 08e72c5..d12943a 100755 --- a/RaspberryJamMod.iss +++ b/RaspberryJamMod.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "RaspberryJamMod" -#define MyAppVersion "0.93" +#define MyAppVersion "0.94" #define MyAppPublisher "Omega Centauri Software" #define MyAppURL "http://github.com/arpruss/raspberryjammod" diff --git a/build.sh b/build.sh index bf5e086..365502d 100755 --- a/build.sh +++ b/build.sh @@ -1,29 +1,29 @@ -NOINSTALLER="" -NOINSTALL="" -for arg in "$@" -do - if [ "$arg" = "noinstaller" ] - then - echo "Will not build installer" - NOINSTALLER=$arg - fi - if [ "$arg" = "noinstall" ] - then - echo "Will not install mod" - NOINSTALL=$arg - fi -done -(cd 19 && sh fast.sh $NOINSTALL) -(cd 194 && sh fast.sh $NOINSTALL) -(cd 110 && sh fast.sh $NOINSTALL) -(cd 111 && sh fast.sh $NOINSTALL) -(cd 112 && sh fast.sh $NOINSTALL) -sh fast.sh $NOINSTALL -sh zip-scripts.sh -(cd build/out && zip -9r ../mods *) -cp build/mods.zip . -if [ "$NOINSTALLER" != "noinstaller" ] -then - ./makesetup.sh -fi -cp python-scripts.zip build/ +NOINSTALLER="" +NOINSTALL="" +for arg in "$@" +do + if [ "$arg" = "noinstaller" ] + then + echo "Will not build installer" + NOINSTALLER=$arg + fi + if [ "$arg" = "noinstall" ] + then + echo "Will not install mod" + NOINSTALL=$arg + fi +done +(cd 19 && sh fast.sh $NOINSTALL) +(cd 194 && sh fast.sh $NOINSTALL) +(cd 110 && sh fast.sh $NOINSTALL) +(cd 111 && sh fast.sh $NOINSTALL) +(cd 112 && sh fast.sh $NOINSTALL) +sh fast.sh $NOINSTALL +sh zip-scripts.sh +(cd build/out && zip -9r ../mods *) +cp build/mods.zip . +if [ "$NOINSTALLER" != "noinstaller" ] +then + ./makesetup.sh +fi +cp python-scripts.zip build/ diff --git a/fast.sh b/fast.sh index 9f381e9..687c867 100644 --- a/fast.sh +++ b/fast.sh @@ -1,5 +1,6 @@ rm build/libs/Raspberr*.jar 2> /dev/null -./gradlew --offline build +./gradlew build +# --offline build mv build/libs/Raspberr* build/libs/RaspberryJamMod.jar mkdir build/out 2> /dev/null mkdir build/out/1.8 2> /dev/null diff --git a/mcpipy/mcpi/entity.py b/mcpipy/mcpi/entity.py index 9679685..8f77da0 100755 --- a/mcpipy/mcpi/entity.py +++ b/mcpipy/mcpi/entity.py @@ -1,3 +1,26 @@ +class Entity: + '''Minecraft PI entity description for RaspberryJuice compatibility''' + + def __init__(self, id, name = None): + self.id = id + self.name = name + + def __cmp__(self, rhs): + return hash(self) - hash(rhs) + + def __eq__(self, rhs): + return self.id == rhs.id + + def __hash__(self): + return self.id + + def __iter__(self): + '''Allows an Entity to be sent whenever id is needed''' + return iter((self.id,)) + + def __repr__(self): + return 'Entity(%d)'%(self.id) + ITEM = "Item" XPORB = "XPOrb" LEASHKNOT = "LeashKnot" diff --git a/mcpipy/mcpi/minecraft.py b/mcpipy/mcpi/minecraft.py index ef6064e..945f422 100644 --- a/mcpipy/mcpi/minecraft.py +++ b/mcpipy/mcpi/minecraft.py @@ -5,6 +5,7 @@ from .block import Block import math from os import environ +from .entity import Entity from .util import flatten,floorFlatten try: from .security import AUTHENTICATION_PASSWORD,AUTHENTICATION_USERNAME @@ -130,6 +131,18 @@ def postToChat(self, id, msg): self.conn.send(self.pkg + ".chat.post", id, str(msg).replace("\r"," ").replace("\n"," ")) + def getEntities(self, *args): + """Return a list of entities near player (playerEntityId:int, [distanceFromPlayerInBlocks:int]) => [[entityId:int,entityTypeId:int,entityTypeName:str,posX:float,posY:float,posZ:float]]""" + """If distanceFromPlayerInBlocks:int is not specified then default 10 blocks will be used""" + s = self.conn.sendReceive("entity.getEntities", args) + entities = [e for e in s.split("|") if e] + return [ [int(n.split(",")[0]), int(n.split(",")[1]), n.split(",")[2], float(n.split(",")[3]), float(n.split(",")[4]), float(n.split(",")[5])] for n in entities] + + def removeEntityType(self, *args): + """Remove entities all entities near player by type (playerEntityId:int, entityTypeId:int, [distanceFromPlayerInBlocks:int]) => (removedEntitiesCount:int)""" + """If distanceFromPlayerInBlocks:int is not specified then default 10 blocks will be used""" + return int(self.conn.sendReceive("entity.removeEntityType", args)) + class CmdPlayer(CmdPositioner): """Methods for the host (Raspberry Pi) player""" def __init__(self, connection, playerId=(), name=None): @@ -385,7 +398,11 @@ def getPlayerId(self, *args): return self.playerId else: return int(self.conn.sendReceive_flat("world.getPlayerId", flatten(args))) - + + def getPlayerEntityId(self, *args): + """Get the id of the current player - RaspberryJuice syntax""" + return self.getPlayerId(args) + def getPlayerEntityIds(self): """Get the entity ids of the connected players => [id:int]""" ids = self.conn.sendReceive("world.getPlayerIds") @@ -407,6 +424,22 @@ def setting(self, setting, status): """Set a world setting (setting, status). keys: world_immutable, nametags_visible""" self.conn.send("world.setting", setting, 1 if bool(status) else 0) + def getEntityTypes(self): + """Return a list of Entity objects representing all the entity types in Minecraft""" + s = self.conn.sendReceive("world.getEntityTypes") + types = [t for t in s.split("|") if t] + return [Entity(int(e[:e.find(",")]), e[e.find(",") + 1:]) for e in types] + + def getEntities(self): + """Return a list of all currently loaded entities () => [[entityId:int,entityTypeId:int,entityTypeName:str,posX:float,posY:float,posZ:float]]""" + s = self.conn.sendReceive("world.getEntities") + entities = [e for e in s.split("|") if e] + return [[int(n.split(",")[0]), int(n.split(",")[1]), n.split(",")[2], float(n.split(",")[3]), float(n.split(",")[4]), float(n.split(",")[5])] for n in entities] + + def removeEntityType(self, entityTypeId): + """Remove entities all currently loaded Entities by type (entityTypeId:int) => (removedEntitiesCount:int)""" + return int(self.conn.sendReceive("world.removeEntityType", int(entityTypeId))) + @staticmethod def create(address = None, port = None, name = None): return Minecraft(Connection(address, port), name = name) diff --git a/mods.zip b/mods.zip index a581789..c9436cc 100644 Binary files a/mods.zip and b/mods.zip differ