Breaking
This commit is contained in:
@@ -298,6 +298,6 @@ public class RefinedStorageUtils {
|
||||
}
|
||||
|
||||
public static void reRenderBlock(World world, BlockPos pos) {
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 1 | 2);
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 2 | 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class BlockMachine extends BlockBase {
|
||||
super.onNeighborBlockChange(world, pos, state, neighborBlock);
|
||||
|
||||
if (!world.isRemote) {
|
||||
((TileMachine) world.getTileEntity(pos)).searchController();
|
||||
((TileMachine) world.getTileEntity(pos)).searchController(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,79 +102,79 @@ 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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
syncItems();
|
||||
|
||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||
taskToCancel.onCancelled(this);
|
||||
}
|
||||
|
||||
craftingTasks.removeAll(craftingTasksToCancel);
|
||||
craftingTasksToCancel.clear();
|
||||
|
||||
craftingTasks.addAll(craftingTasksToAdd);
|
||||
craftingTasksToAdd.clear();
|
||||
|
||||
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||
|
||||
while (craftingTaskIterator.hasNext()) {
|
||||
ICraftingTask task = craftingTaskIterator.next();
|
||||
|
||||
if (ticks % task.getPattern().getCrafter(worldObj).getSpeed() == 0 && task.update(this)) {
|
||||
task.onDone(this);
|
||||
|
||||
craftingTaskIterator.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disconnectAll();
|
||||
newEnergyUsage += machine.getEnergyUsage();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
syncItems();
|
||||
|
||||
for (ICraftingTask taskToCancel : craftingTasksToCancel) {
|
||||
taskToCancel.onCancelled(this);
|
||||
}
|
||||
|
||||
craftingTasks.removeAll(craftingTasksToCancel);
|
||||
craftingTasksToCancel.clear();
|
||||
|
||||
craftingTasks.addAll(craftingTasksToAdd);
|
||||
craftingTasksToAdd.clear();
|
||||
|
||||
Iterator<ICraftingTask> craftingTaskIterator = craftingTasks.iterator();
|
||||
|
||||
while (craftingTaskIterator.hasNext()) {
|
||||
ICraftingTask task = craftingTaskIterator.next();
|
||||
|
||||
if (ticks % task.getPattern().getCrafter(worldObj).getSpeed() == 0 && task.update(this)) {
|
||||
task.onDone(this);
|
||||
|
||||
craftingTaskIterator.remove();
|
||||
}
|
||||
}
|
||||
/*} else {
|
||||
disconnectAll();
|
||||
}*/
|
||||
|
||||
wirelessGridRange = newWirelessGridRange;
|
||||
energyUsage = newEnergyUsage;
|
||||
storages = newStorages;
|
||||
@@ -208,7 +208,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastEnergy != energy.getEnergyStored()) {
|
||||
if (lastEnergy != energy.getEnergyStored() || ticks == 1) {
|
||||
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
||||
|
||||
if (System.currentTimeMillis() - lastEnergyUpdate > 3000L) {
|
||||
@@ -216,8 +216,6 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
|
||||
lastEnergyUpdate = System.currentTimeMillis();
|
||||
}
|
||||
} else if (ticks < 10) {
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageControllerEnergyUpdate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.block.BlockMachine;
|
||||
import refinedstorage.network.MessageMachineConnectedUpdate;
|
||||
@@ -25,7 +26,14 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
return controller;
|
||||
}
|
||||
|
||||
public void searchController() {
|
||||
// We use a world parameter here and not worldObj because in BlockMachine.onNeighborBlockChange
|
||||
// this method is called and at that point in time worldObj is not set yet.
|
||||
public void searchController(World world) {
|
||||
// @TODO: Give onConnected and onDisconnected a world param
|
||||
if (worldObj == null) {
|
||||
worldObj = world;
|
||||
}
|
||||
|
||||
visited.clear();
|
||||
|
||||
TileController newController = ControllerSearcher.search(worldObj, pos, visited);
|
||||
@@ -49,7 +57,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
if (ticks == 1) {
|
||||
block = worldObj.getBlockState(pos).getBlock();
|
||||
|
||||
searchController();
|
||||
searchController(worldObj);
|
||||
}
|
||||
|
||||
if (connected && !redstoneMode.isEnabled(worldObj, pos)) {
|
||||
|
||||
Reference in New Issue
Block a user