Skip to content

Commit

Permalink
Moving multiblock-change processing to occur prior to tickBegin(). Th…
Browse files Browse the repository at this point in the history
…is eliminates a one-tick race condition when breaking blocks, whereby a dirty controller with missing blocks could be erroneously ticked.
  • Loading branch information
erogenousbeef-zz committed Apr 4, 2015
1 parent 5d18c1f commit dc07c85
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public class MultiblockClientTickHandler {
public void onClientTick(TickEvent.ClientTickEvent event) {
if(event.phase == TickEvent.Phase.START) {
MultiblockRegistry.tickStart(Minecraft.getMinecraft().theWorld);
} else if(event.phase == TickEvent.Phase.END) { //Probably could just to else, but better to be safe than sorry
MultiblockRegistry.tickEnd(Minecraft.getMinecraft().theWorld);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,11 @@ public class MultiblockRegistry {
public static void tickStart(World world) {
if(registries.containsKey(world)) {
MultiblockWorldRegistry registry = registries.get(world);
registry.processMultiblockChanges();
registry.tickStart();
}
}

/**
* Called after Tile Entities are ticked in the world.
* @param world The world being ticked
*/
public static void tickEnd(World world) {
if(registries.containsKey(world)) {
MultiblockWorldRegistry registry = registries.get(world);
registry.tickEnd();
}
}

/**
* Called when the world has finished loading a chunk.
* @param world The world which has finished loading a chunk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class MultiblockServerTickHandler {
public void onWorldTick(TickEvent.WorldTickEvent event) {
if(event.phase == TickEvent.Phase.START) {
MultiblockRegistry.tickStart(event.world);
} else if(event.phase == TickEvent.Phase.END) {
MultiblockRegistry.tickEnd(event.world);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MultiblockWorldRegistry(World world) {
}

/**
* Called before Tile Entities are ticked in the world. Run gamelogic.
* Called before Tile Entities are ticked in the world. Run game logic.
*/
public void tickStart() {
if(controllers.size() > 0) {
Expand All @@ -84,9 +84,9 @@ public void tickStart() {
}

/**
* Called after Tile Entities are ticked in the world. Do bookkeeping.
* Called prior to processing multiblock controllers. Do bookkeeping.
*/
public void tickEnd() {
public void processMultiblockChanges() {
IChunkProvider chunkProvider = worldObj.getChunkProvider();
CoordTriplet coord;

Expand Down

0 comments on commit dc07c85

Please sign in to comment.