Bugfixes
This commit is contained in:
@@ -12,6 +12,8 @@ import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class MessageControllerEnergyUpdate implements IMessage, IMessageHandler<MessageControllerEnergyUpdate, IMessage> {
|
||||
public static long LAST_RE_RENDER;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
@@ -52,9 +54,15 @@ public class MessageControllerEnergyUpdate implements IMessage, IMessageHandler<
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileController) {
|
||||
int lastEnergy = ((TileController) tile).getEnergyStored(null);
|
||||
|
||||
((TileController) tile).setEnergyStored(message.energy);
|
||||
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
if (lastEnergy != message.energy && System.currentTimeMillis() - LAST_RE_RENDER > 3000) {
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
|
||||
LAST_RE_RENDER = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -52,9 +52,13 @@ public class MessageDetectorPoweredUpdate implements IMessage, IMessageHandler<M
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileDetector) {
|
||||
boolean wasPowered = ((TileDetector) tile).isPowered();
|
||||
|
||||
((TileDetector) tile).setPowered(message.powered);
|
||||
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
if (wasPowered != message.powered) {
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -52,9 +52,13 @@ public class MessageMachineConnectedUpdate implements IMessage, IMessageHandler<
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileMachine) {
|
||||
boolean wasConnected = ((TileMachine) tile).isConnected();
|
||||
|
||||
((TileMachine) tile).setConnected(message.connected);
|
||||
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
if (wasConnected != message.connected) {
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -52,9 +52,13 @@ public class MessageSoldererWorkingUpdate implements IMessage, IMessageHandler<M
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileSolderer) {
|
||||
boolean wasWorking = ((TileSolderer) tile).isWorking();
|
||||
|
||||
((TileSolderer) tile).setWorking(message.working);
|
||||
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
if (wasWorking != message.working) {
|
||||
RefinedStorageUtils.reRenderBlock(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -74,8 +74,6 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
|
||||
private int wirelessGridRange;
|
||||
|
||||
private long lastEnergyUpdate;
|
||||
|
||||
public void addMachine(TileMachine machine) {
|
||||
machinesToAdd.add(machine);
|
||||
}
|
||||
@@ -102,78 +100,78 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
List<IStorage> newStorages = new ArrayList<IStorage>();
|
||||
List<CraftingPattern> newPatterns = new ArrayList<CraftingPattern>();
|
||||
|
||||
//if (canRun()) {
|
||||
newEnergyUsage = 10;
|
||||
if (canRun()) {
|
||||
newEnergyUsage = 10;
|
||||
|
||||
for (TileMachine machine : machines) {
|
||||
machine.updateMachine();
|
||||
for (TileMachine machine : machines) {
|
||||
machine.updateMachine();
|
||||
|
||||
if (machine instanceof TileWirelessTransmitter) {
|
||||
newWirelessGridRange += ((TileWirelessTransmitter) machine).getRange();
|
||||
}
|
||||
if (machine instanceof TileWirelessTransmitter) {
|
||||
newWirelessGridRange += ((TileWirelessTransmitter) machine).getRange();
|
||||
}
|
||||
|
||||
if (machine instanceof IStorageProvider) {
|
||||
((IStorageProvider) machine).provide(newStorages);
|
||||
}
|
||||
if (machine instanceof IStorageProvider) {
|
||||
((IStorageProvider) machine).provide(newStorages);
|
||||
}
|
||||
|
||||
if (machine instanceof TileCrafter) {
|
||||
TileCrafter crafter = (TileCrafter) machine;
|
||||
if (machine instanceof TileCrafter) {
|
||||
TileCrafter crafter = (TileCrafter) machine;
|
||||
|
||||
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
|
||||
if (crafter.getStackInSlot(i) != null) {
|
||||
ItemStack pattern = crafter.getStackInSlot(i);
|
||||
for (int i = 0; i < TileCrafter.PATTERN_SLOTS; ++i) {
|
||||
if (crafter.getStackInSlot(i) != null) {
|
||||
ItemStack pattern = crafter.getStackInSlot(i);
|
||||
|
||||
newPatterns.add(new CraftingPattern(
|
||||
crafter.getPos().getX(),
|
||||
crafter.getPos().getY(),
|
||||
crafter.getPos().getZ(),
|
||||
ItemPattern.isProcessing(pattern),
|
||||
ItemPattern.getInputs(pattern),
|
||||
ItemPattern.getOutputs(pattern)));
|
||||
newPatterns.add(new CraftingPattern(
|
||||
crafter.getPos().getX(),
|
||||
crafter.getPos().getY(),
|
||||
crafter.getPos().getZ(),
|
||||
ItemPattern.isProcessing(pattern),
|
||||
ItemPattern.getInputs(pattern),
|
||||
ItemPattern.getOutputs(pattern)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newEnergyUsage += machine.getEnergyUsage();
|
||||
}
|
||||
|
||||
newEnergyUsage += machine.getEnergyUsage();
|
||||
}
|
||||
Collections.sort(storages, new Comparator<IStorage>() {
|
||||
@Override
|
||||
public int compare(IStorage s1, IStorage s2) {
|
||||
if (s1.getPriority() == s2.getPriority()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Collections.sort(storages, new Comparator<IStorage>() {
|
||||
@Override
|
||||
public int compare(IStorage s1, IStorage s2) {
|
||||
if (s1.getPriority() == s2.getPriority()) {
|
||||
return 0;
|
||||
return (s1.getPriority() > s2.getPriority()) ? -1 : 1;
|
||||
}
|
||||
});
|
||||
|
||||
return (s1.getPriority() > s2.getPriority()) ? -1 : 1;
|
||||
syncItems();
|
||||
|
||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||
taskToCancel.onCancelled(this);
|
||||
}
|
||||
});
|
||||
|
||||
syncItems();
|
||||
craftingTasks.removeAll(craftingTasksToCancel);
|
||||
craftingTasksToCancel.clear();
|
||||
|
||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||
taskToCancel.onCancelled(this);
|
||||
}
|
||||
craftingTasks.addAll(craftingTasksToAdd);
|
||||
craftingTasksToAdd.clear();
|
||||
|
||||
craftingTasks.removeAll(craftingTasksToCancel);
|
||||
craftingTasksToCancel.clear();
|
||||
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||
|
||||
craftingTasks.addAll(craftingTasksToAdd);
|
||||
craftingTasksToAdd.clear();
|
||||
while (craftingTaskIterator.hasNext()) {
|
||||
ICraftingTask task = craftingTaskIterator.next();
|
||||
|
||||
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||
if (ticks % task.getPattern().getCrafter(worldObj).getSpeed() == 0 && task.update(this)) {
|
||||
task.onDone(this);
|
||||
|
||||
while (craftingTaskIterator.hasNext()) {
|
||||
ICraftingTask task = craftingTaskIterator.next();
|
||||
|
||||
if (ticks % task.getPattern().getCrafter(worldObj).getSpeed() == 0 && task.update(this)) {
|
||||
task.onDone(this);
|
||||
|
||||
craftingTaskIterator.remove();
|
||||
craftingTaskIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*} else {
|
||||
} else {
|
||||
disconnectAll();
|
||||
}*/
|
||||
}
|
||||
|
||||
wirelessGridRange = newWirelessGridRange;
|
||||
energyUsage = newEnergyUsage;
|
||||
@@ -208,14 +206,10 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastEnergy != energy.getEnergyStored() || ticks == 1) {
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageControllerEnergyUpdate(this));
|
||||
|
||||
if (lastEnergy != energy.getEnergyStored()) {
|
||||
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
||||
|
||||
if (System.currentTimeMillis() - lastEnergyUpdate > 3000L) {
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageControllerEnergyUpdate(this));
|
||||
|
||||
lastEnergyUpdate = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
|
||||
if (powered != lastPowered) {
|
||||
worldObj.notifyNeighborsOfStateChange(pos, RefinedStorageBlocks.DETECTOR);
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageDetectorPoweredUpdate(this));
|
||||
}
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageDetectorPoweredUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
searchController(worldObj);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
|
||||
|
||||
if (connected && !redstoneMode.isEnabled(worldObj, pos)) {
|
||||
onDisconnected();
|
||||
}
|
||||
@@ -72,8 +74,6 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
|
||||
if (worldObj.getBlockState(pos).getBlock() == block) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
|
||||
}
|
||||
|
||||
worldObj.notifyNeighborsOfStateChange(pos, block);
|
||||
@@ -86,12 +86,10 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
|
||||
if (worldObj.getBlockState(pos).getBlock() == block) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
|
||||
}
|
||||
|
||||
// I have no idea why this is needed
|
||||
if (controller != null) {
|
||||
if (this.controller != null) {
|
||||
this.controller.removeMachine(this);
|
||||
this.controller = null;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
|
||||
public void updateMachine() {
|
||||
ISoldererRecipe newRecipe = SoldererRegistry.getRecipe(inventory);
|
||||
|
||||
boolean lastWorking = working;
|
||||
|
||||
if (newRecipe == null) {
|
||||
reset();
|
||||
} else if (newRecipe != recipe) {
|
||||
@@ -78,9 +76,7 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
|
||||
}
|
||||
}
|
||||
|
||||
if (working != lastWorking) {
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageSoldererWorkingUpdate(this));
|
||||
}
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageSoldererWorkingUpdate(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user