This commit is contained in:
Raoul Van den Berge
2016-05-14 16:41:02 +02:00
parent dd7cee8c8b
commit 440b4cc0bc
4 changed files with 74 additions and 68 deletions

View File

@@ -298,6 +298,6 @@ public class RefinedStorageUtils {
} }
public static void reRenderBlock(World world, BlockPos pos) { 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);
} }
} }

View File

@@ -54,7 +54,7 @@ public abstract class BlockMachine extends BlockBase {
super.onNeighborBlockChange(world, pos, state, neighborBlock); super.onNeighborBlockChange(world, pos, state, neighborBlock);
if (!world.isRemote) { if (!world.isRemote) {
((TileMachine) world.getTileEntity(pos)).searchController(); ((TileMachine) world.getTileEntity(pos)).searchController(world);
} }
} }
} }

View File

@@ -102,7 +102,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
List<IStorage> newStorages = new ArrayList<IStorage>(); List<IStorage> newStorages = new ArrayList<IStorage>();
List<CraftingPattern> newPatterns = new ArrayList<CraftingPattern>(); List<CraftingPattern> newPatterns = new ArrayList<CraftingPattern>();
if (canRun()) { //if (canRun()) {
newEnergyUsage = 10; newEnergyUsage = 10;
for (TileMachine machine : machines) { for (TileMachine machine : machines) {
@@ -171,9 +171,9 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
craftingTaskIterator.remove(); craftingTaskIterator.remove();
} }
} }
} else { /*} else {
disconnectAll(); disconnectAll();
} }*/
wirelessGridRange = newWirelessGridRange; wirelessGridRange = newWirelessGridRange;
energyUsage = newEnergyUsage; energyUsage = newEnergyUsage;
@@ -208,7 +208,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
break; break;
} }
if (lastEnergy != energy.getEnergyStored()) { if (lastEnergy != energy.getEnergyStored() || ticks == 1) {
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER); worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
if (System.currentTimeMillis() - lastEnergyUpdate > 3000L) { if (System.currentTimeMillis() - lastEnergyUpdate > 3000L) {
@@ -216,8 +216,6 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
lastEnergyUpdate = System.currentTimeMillis(); lastEnergyUpdate = System.currentTimeMillis();
} }
} else if (ticks < 10) {
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageControllerEnergyUpdate(this));
} }
} }
} }

View File

@@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
import refinedstorage.block.BlockMachine; import refinedstorage.block.BlockMachine;
import refinedstorage.network.MessageMachineConnectedUpdate; import refinedstorage.network.MessageMachineConnectedUpdate;
@@ -25,7 +26,14 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
return controller; 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(); visited.clear();
TileController newController = ControllerSearcher.search(worldObj, pos, visited); TileController newController = ControllerSearcher.search(worldObj, pos, visited);
@@ -49,7 +57,7 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
if (ticks == 1) { if (ticks == 1) {
block = worldObj.getBlockState(pos).getBlock(); block = worldObj.getBlockState(pos).getBlock();
searchController(); searchController(worldObj);
} }
if (connected && !redstoneMode.isEnabled(worldObj, pos)) { if (connected && !redstoneMode.isEnabled(worldObj, pos)) {