From 93a6a80fba2fad1cbf16cc32080bcf2fdb0b61c2 Mon Sep 17 00:00:00 2001 From: arpruss Date: Sun, 21 Jun 2015 08:29:47 -0500 Subject: [PATCH] better drawing order --- python2-scripts/mcpipy/vehicle.py | 17 +++++- .../raspberryjammod/APIHandler.java | 6 ++- .../raspberryjammod/MCEventHandler.java | 52 ++++++++++++------- .../NightVisionExternalCommand.java | 4 +- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/python2-scripts/mcpipy/vehicle.py b/python2-scripts/mcpipy/vehicle.py index b5d9a32..931a9b4 100755 --- a/python2-scripts/mcpipy/vehicle.py +++ b/python2-scripts/mcpipy/vehicle.py @@ -41,6 +41,16 @@ TERRAIN = set((AIR.id,WATER_FLOWING.id,WATER_STATIONARY.id,GRASS.id,DIRT.id,LAVA_FLOWING.id, LAVA_STATIONARY.id,GRASS.id,DOUBLE_TALLGRASS.id,GRASS_TALL.id,BEDROCK.id,GRAVEL.id)) +NEED_SUPPORT = set((SAPLING.id,WATER_FLOWING.id,LAVA_FLOWING.id,GRASS_TALL.id,34,35,FLOWER_YELLOW.id, + FLOWER_CYAN.id,MUSHROOM_BROWN.id,MUSHROOM_RED.id,TORCH.id,63,DOOR_WOOD.id,LADDER.id, + 66,68,69,70,DOOR_IRON.id,72,75,76,77,SUGAR_CANE.id,93,94,96,104,105,106,108,111, + 113,115,116,117,122,127,131,132,141,142,143,145,147,148,149,150,151,154,157, + 167,CARPET.id,SUNFLOWER.id,176,177,178,183,184,185,186,187,188,189,190,191,192, + 193,194,195,196,197)) + +def keyFunction(dict,pos): + return (dict[pos].id in NEED_SUPPORT,pos) + def box(x0,y0,z0,x1,y1,z1): for x in range(x0,x1+1): for y in range(y0,y1+1): @@ -73,6 +83,7 @@ def scan(x0,y0,z0): while len(newlyAdded)>0: adding = set() + mc.postToChat("Added "+str(len(newlyAdded))+" blocks") for q in newlyAdded: for x,y,z in box(-1,-1,-1,1,1,1): pos = (x+q[0],y+q[1],z+q[2]) @@ -92,7 +103,7 @@ def scan(x0,y0,z0): offsets = {} - for pos in positions: + for pos in sorted(positions, key=lambda x : keyFunction(positions,x)): offsets[(pos[0]-x0,pos[1]-y0,pos[2]-z0)] = positions[pos] if flash: setBlockWithData(pos,positions[pos]) @@ -220,8 +231,10 @@ def translate(base,x,y,z): if curBlock == block: del todo[pos] saved[pos] = curBlock - for pos in sorted(todo): +# mc.setting("pause_drawing",1) + for pos in sorted(todo, key=lambda x : keyFunction(todo,x)): setBlockWithData(pos,todo[pos]) +# mc.setting("pause_drawing",0) oldVehicle = newVehicle oldPos = vehiclePos oldRotation = vehicleRotation diff --git a/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java b/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java index c2de4c5..1798d07 100755 --- a/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java +++ b/src/main/java/mobi/omegacentauri/raspberryjammod/APIHandler.java @@ -458,10 +458,12 @@ else if (cmd.equals(EVENTSCHATPOSTS)) { } else if (cmd.equals(WORLDSETTING)) { String setting = scan.next(); - if (setting.equals("world_immutable")) + if (setting.equals("world_immutable")) // across connections eventHandler.setStopChanges(scan.nextInt() != 0); - else if (setting.equals("include_nbt_with_data")) + else if (setting.equals("include_nbt_with_data")) // connection-specific includeNBTWithData = (scan.nextInt() != 0); + else if (setting.equals("pause_drawing")) // across connections + eventHandler.setPause(scan.nextInt() != 0); // name_tags not supported } else if (cmd.equals(EVENTSSETTING)) { diff --git a/src/main/java/mobi/omegacentauri/raspberryjammod/MCEventHandler.java b/src/main/java/mobi/omegacentauri/raspberryjammod/MCEventHandler.java index 19c4c5b..3e39d8a 100755 --- a/src/main/java/mobi/omegacentauri/raspberryjammod/MCEventHandler.java +++ b/src/main/java/mobi/omegacentauri/raspberryjammod/MCEventHandler.java @@ -37,16 +37,17 @@ import net.minecraftforge.fml.relauncher.Side; public class MCEventHandler { - List blockActionQueue = new ArrayList(); - List hits = new LinkedList(); - List chats = new LinkedList(); - static final int MAX_HITS = 512; - private boolean stopChanges = false; - private boolean restrictToSword = true; - volatile boolean nightVision = false; - ServerChatEvent chatEvents; - static final int MAX_CHATS = 512; - int clientTickCount = 0; + private List blockActionQueue = new ArrayList(); + private List hits = new LinkedList(); + private List chats = new LinkedList(); + private static final int MAX_HITS = 512; + private volatile boolean stopChanges = false; + private volatile boolean restrictToSword = true; + private volatile boolean nightVision = false; + private volatile boolean pause = false; + private ServerChatEvent chatEvents; + private static final int MAX_CHATS = 512; + private int clientTickCount = 0; public void setStopChanges(boolean stopChanges) { this.stopChanges = stopChanges; @@ -179,15 +180,17 @@ public void onClientTick(TickEvent.ClientTickEvent event) { @SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent event) { - World world = MinecraftServer.getServer().getEntityWorld(); - - synchronized(blockActionQueue) { - for (SetBlockState entry: blockActionQueue) { - if (! RaspberryJamMod.active) - break; - entry.execute(world); + if (!pause) { + World world = MinecraftServer.getServer().getEntityWorld(); + + synchronized(blockActionQueue) { + for (SetBlockState entry: blockActionQueue) { + if (! RaspberryJamMod.active) + break; + entry.execute(world); + } + blockActionQueue.clear(); } - blockActionQueue.clear(); } } @@ -302,4 +305,17 @@ public String getDescription() { } + public void setPause(boolean b) { + pause = b; + } + + public void setNightVision(boolean b) { + nightVision = b; + } + + public boolean getNightVision() { + return nightVision; + } + + } diff --git a/src/main/java/mobi/omegacentauri/raspberryjammod/NightVisionExternalCommand.java b/src/main/java/mobi/omegacentauri/raspberryjammod/NightVisionExternalCommand.java index 59eb1e4..dfdbcf9 100755 --- a/src/main/java/mobi/omegacentauri/raspberryjammod/NightVisionExternalCommand.java +++ b/src/main/java/mobi/omegacentauri/raspberryjammod/NightVisionExternalCommand.java @@ -63,7 +63,7 @@ public void execute(ICommandSender sender, String[] args) boolean nv; if (args.length == 0) { - nv = ! eventHandler.nightVision; + nv = ! eventHandler.getNightVision(); } else if (args[0].toLowerCase().equals("on")) { nv = true; @@ -75,7 +75,7 @@ else if (args[0].toLowerCase().equals("off")) { throw new CommandException("Usage: /nightvision [on|off]"); } - eventHandler.nightVision = nv; + eventHandler.setNightVision(nv); EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player != null) { if (nv) {