Skip to content

Commit

Permalink
0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jun 20, 2015
1 parent 591b43c commit d5544ed
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 20 deletions.
2 changes: 1 addition & 1 deletion RaspberryJamMod.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "RaspberryJamMod"
#define MyAppVersion "0.28"
#define MyAppVersion "0.29"
#define MyAppPublisher "Omega Centauri Software"
#define MyAppURL "http://github.com/arpruss/raspberryjammod"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "0.28"
version = "0.29"
group= "mobi.omegacentauri.raspberryjammod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "RaspberryJamMod"

Expand Down
4 changes: 3 additions & 1 deletion go.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
./zip.sh
rm build/libs/*
./gradlew.bat --offline build
mv build/libs/Raspberr* build/libs/RaspberryJamMod.jar
cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/
cp build/libs/RaspberryJamMod.jar $APPDATA/.minecraft/mods/
./makesetup.sh
Binary file modified python2-scripts.zip
Binary file not shown.
Binary file modified python3-scripts.zip
Binary file not shown.
Empty file removed python3-scripts/mcpipy/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions python3-scripts/mcpipy/digitalclock.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#
# Code under the MIT license by Alexander Pruss
#

from mc import *
import text
import datetime
Expand Down
21 changes: 11 additions & 10 deletions python3-scripts/mcpipy/mandelbulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Options for half: south, north, east, west, up, down

from mc import *
import mcpi.settings
import mcpi.settings as settings
import cmath
import time
import sys
Expand All @@ -34,6 +34,7 @@
half = sys.argv[3].lower()[0]

palette = list(reversed([WOOL_WHITE,HARDENED_CLAY_STAINED_WHITE,WOOL_PINK,WOOL_LIGHT_GRAY,WOOL_LIGHT_BLUE,WOOL_MAGENTA,WOOL_PURPLE,HARDENED_CLAY_STAINED_LIGHT_BLUE,HARDENED_CLAY_STAINED_LIGHT_GRAY,HARDENED_CLAY_STAINED_MAGENTA,HARDENED_CLAY_STAINED_PINK,HARDENED_CLAY_STAINED_RED,WOOL_RED,REDSTONE_BLOCK,HARDENED_CLAY_STAINED_ORANGE,WOOL_ORANGE,HARDENED_CLAY_STAINED_YELLOW,WOOL_YELLOW,WOOL_LIME,HARDENED_CLAY_STAINED_LIME,HARDENED_CLAY_STAINED_PURPLE,HARDENED_CLAY_STAINED_CYAN,WOOL_CYAN,WOOL_BLUE,HARDENED_CLAY_STAINED_BLUE,WOOL_GRAY,HARDENED_CLAY_STAINED_GREEN,WOOL_GREEN,HARDENED_CLAY_STAINED_BROWN,WOOL_BROWN,HARDENED_CLAY_STAINED_GRAY,WOOL_BLACK]));
if settings.isPE:

def calculate(pos):
x,z,y = pos[0],pos[1],pos[2]
Expand Down Expand Up @@ -86,23 +87,23 @@ def toBulb(centerMC,centerBulb,scale,x,y,z):
def draw():
count = 0

rangeX = list(range(cornerMC.x, cornerMC.x+size))
rangeY = list(range(cornerMC.y, cornerMC.y+size))
rangeZ = list(range(cornerMC.z, cornerMC.z+size))
rangeX = range(cornerMC.x, cornerMC.x+size)
rangeY = range(cornerMC.y, cornerMC.y+size)
rangeZ = range(cornerMC.z, cornerMC.z+size)

if not half is None:
if half == 'w':
rangeX = list(range(cornerMC.x, cornerMC.x+size/2))
rangeX = range(cornerMC.x, cornerMC.x+size/2)
elif half == 'e':
rangeX = list(range(cornerMC.x+size/2, cornerMC.x+size))
rangeX = range(cornerMC.x+size/2, cornerMC.x+size)
elif half == 'n':
rangeZ = list(range(cornerMC.z, cornerMC.z+size/2))
rangeZ = range(cornerMC.z, cornerMC.z+size/2)
elif half == 's':
rangeZ = list(range(cornerMC.z+size/2, cornerMC.z+size))
rangeZ = range(cornerMC.z+size/2, cornerMC.z+size)
elif half == 'u':
rangeY = list(range(cornerMC.y+size/2, cornerMC.y+size))
rangeY = range(cornerMC.y+size/2, cornerMC.y+size)
elif half == 'd':
rangeY = list(range(cornerMC.y, cornerMC.y+size/2))
rangeY = range(cornerMC.y, cornerMC.y+size/2)

for mcX in rangeX:
for mcY in rangeY:
Expand Down
105 changes: 105 additions & 0 deletions python3-scripts/mcpipy/vehicle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Code under the MIT license by Alexander Pruss
#

#
# Make a moving vehicle out of whatever the player is standing on, within a set distance
#

from mc import *
import time
import sys

try:
MAX_DISTANCE_FROM_PLAYER = int(sys.argv[0])
except:
MAX_DISTANCE_FROM_PLAYER = 25

# the following blocks do not count as part of the vehicle
SKIP = set((AIR.id,WATER_FLOWING.id,WATER_STATIONARY.id,GRASS.id,DIRT.id,LAVA_FLOWING.id,LAVA_STATIONARY.id))

def scan(dict,startPos,curPos=None):
global highWater
if curPos is not None:
block = mc.getBlockWithData(curPos[0]+startPos[0],curPos[1]+startPos[1],curPos[2]+startPos[2])

if block.id in SKIP:
if (block.id == WATER_STATIONARY.id or block.id == WATER_FLOWING.id) and (highWater is None or highWater < curPos[1]+startPos[1]):
highWater = curPos[1]+startPos[1]
return
else:
dict[curPos] = block
else:
curPos = (0,0,0)

for x in range(-1,2):
for y in range(-1,2):
for z in range(-1,2):
pos = (x+curPos[0],y+curPos[1],z+curPos[2])
if ( pos not in dict and abs(pos[0]) <= MAX_DISTANCE_FROM_PLAYER and
abs(pos[1]) <= MAX_DISTANCE_FROM_PLAYER and
abs(pos[2]) <= MAX_DISTANCE_FROM_PLAYER ):
scan(dict,startPos,pos)

def rotate(dict, amount):
if amount == 0:
return dict
out = {}
if amount == 1:
for pos in dict:
out[(-pos[2],pos[1],pos[0])] = dict[pos]
elif amount == 2:
for pos in dict:
out[(-pos[0],pos[1],-pos[2])] = dict[pos]
else:
for pos in dict:
out[(pos[2],pos[1],-pos[0])] = dict[pos]
return out

def translate(base,x,y,z):
out = {}
for pos in base:
out[(x+pos[0],y+pos[1],z+pos[2])] = base[pos]
return out

mc = Minecraft()

vehiclePos = mc.player.getTilePos()
vehicleRotation = int(round(mc.player.getRotation() / 90.)) % 4

highWater = None
baseVehicle = {}
mc.postToChat("Scanning")
scan(baseVehicle,(vehiclePos.x,vehiclePos.y,vehiclePos.z))
mc.postToChat("Number of blocks: "+str(len(baseVehicle)))
if len(baseVehicle) == 0:
mc.postToChat("Make a vehicle and then stand on it when starting this script.")
exit()
else:
mc.postToChat("Now walk around.")

oldVehicle = translate(baseVehicle,vehiclePos.x,vehiclePos.y,vehiclePos.z)
oldPos = vehiclePos
oldRotation = vehicleRotation

while True:
vehiclePos = mc.player.getTilePos()
vehicleRotation = int(round(mc.player.getRotation() / 90.)) % 4
if vehicleRotation != oldRotation:
baseVehicle = rotate(baseVehicle,(vehicleRotation-oldRotation)%4)
if vehiclePos != oldPos or vehicleRotation != oldRotation:
newVehicle = translate(baseVehicle,vehiclePos.x,vehiclePos.y,vehiclePos.z)
todo = {}
for pos in oldVehicle:
if pos not in newVehicle:
todo[pos] = WATER_FLOWING.id if highWater is not None and pos[1] <= highWater else AIR.id
for pos in newVehicle:
block = newVehicle[pos]
if pos not in oldVehicle or oldVehicle[pos] != block:
todo[pos] = block
for pos in todo:
mc.setBlock(pos,todo[pos])
oldVehicle = newVehicle
oldPos = vehiclePos
oldRotation = vehicleRotation
time.sleep(0.25)
35 changes: 33 additions & 2 deletions src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,46 @@ else if (cmd.equals(SETBLOCK)) {
BlockPos pos = getBlockPosition(scan);
short id = scan.nextShort();
short meta = scan.hasNextShort() ? scan.nextShort() : 0;
eventHandler.queueBlockAction(new SetBlockState(pos, id, meta));
String tagString = getRest(scan);

SetBlockState setState;

if (tagString.length() > 0) {
try {
setState = new SetBlockNBT(pos, id, meta, JsonToNBT.func_180713_a(tagString));
} catch (NBTException e) {
setState = new SetBlockState(pos, id, meta);
}
}
else {
setState = new SetBlockState(pos, id, meta);
}

eventHandler.queueBlockAction(setState);
}
else if (cmd.equals(SETBLOCKS)) {
BlockPos pos1 = getBlockPosition(scan);
BlockPos pos2 = getBlockPosition(scan);

short id = scan.nextShort();
short meta = scan.hasNextShort() ? scan.nextShort() : 0;
eventHandler.queueBlockAction(new SetBlocksState(pos1, pos2, id, meta));

String tagString = getRest(scan);

SetBlocksState setState;

if (tagString.length() > 0) {
try {
setState = new SetBlocksNBT(pos1, pos2, id, meta, JsonToNBT.func_180713_a(tagString));
} catch (NBTException e) {
setState = new SetBlocksState(pos1, pos2, id, meta);
}
}
else {
setState = new SetBlocksState(pos1, pos2, id, meta);
}

eventHandler.queueBlockAction(setState);
}
else if (cmd.equals(PLAYERGETPOS)) {
entityGetPos(clientPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import net.minecraft.event.ClickEvent;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class RaspberryJamMod
{
public static final String MODID = "raspberryjammod";
public static final String VERSION = "0.28";
public static final String VERSION = "0.29";
public static final String NAME = "Raspberry Jam Mod";
private APIServer mcc;
private PythonExternalCommand pythonExternalCommand = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public SetBlockState(BlockPos pos, short id, short meta) {
public void execute(World world) {
IBlockState oldState = world.getBlockState(pos);
Block oldBlock = oldState.getBlock();

if (null != world.getTileEntity(pos))
world.removeTileEntity(pos);

if (Block.getIdFromBlock(oldBlock) != (int)id ||
oldBlock.getMetaFromState(oldState) != (int)meta ||
world.getTileEntity(pos) != null)
oldBlock.getMetaFromState(oldState) != (int)meta )
world.setBlockState(pos, Block.getBlockById(id).getStateFromMeta(meta), 3);
// Maybe the update code should be 2? I don't really know.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ public void execute(World world) {
IBlockState oldState = world.getBlockState(here);
Block oldBlock = oldState.getBlock();

if (world.getTileEntity(here) != null) {
world.removeTileEntity(here);
}

if (Block.getIdFromBlock(oldBlock) != intId ||
oldBlock.getMetaFromState(oldState) != intMeta ||
world.getTileEntity(here) != null) {
oldBlock.getMetaFromState(oldState) != intMeta) {
world.setBlockState(here, Block.getBlockById(intId).getStateFromMeta(intMeta), 3);
}
}
Expand Down

0 comments on commit d5544ed

Please sign in to comment.