Bugfixes 2
This commit is contained in:
@@ -292,12 +292,12 @@ public class RefinedStorageUtils {
|
||||
}
|
||||
|
||||
public static void sendToAllAround(World world, BlockPos pos, IMessage message) {
|
||||
NetworkRegistry.TargetPoint target = new NetworkRegistry.TargetPoint(world.provider.getDimensionType().getId(), pos.getX(), pos.getY(), pos.getZ(), 64);
|
||||
NetworkRegistry.TargetPoint target = new NetworkRegistry.TargetPoint(world.provider.getDimensionType().getId(), pos.getX(), pos.getY(), pos.getZ(), 128);
|
||||
|
||||
RefinedStorage.NETWORK.sendToAllAround(message, target);
|
||||
}
|
||||
|
||||
public static void reRenderBlock(World world, BlockPos pos) {
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 2 | 4);
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ public abstract class BlockMachine extends BlockBase {
|
||||
TileMachine machine = (TileMachine) world.getTileEntity(pos);
|
||||
|
||||
if (machine.isConnected()) {
|
||||
machine.onDisconnected();
|
||||
machine.onDisconnected(world);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -228,7 +228,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
|
||||
|
||||
private void disconnectAll() {
|
||||
for (TileMachine machine : machines) {
|
||||
machine.onDisconnected();
|
||||
machine.onDisconnected(worldObj);
|
||||
}
|
||||
|
||||
machines.clear();
|
||||
|
@@ -5,6 +5,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerDetector;
|
||||
@@ -32,8 +33,8 @@ public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
private boolean powered = false;
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
super.onDisconnected();
|
||||
public void onDisconnected(World world) {
|
||||
super.onDisconnected(world);
|
||||
|
||||
powered = false;
|
||||
}
|
||||
|
@@ -29,22 +29,17 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
// 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);
|
||||
|
||||
if (controller == null) {
|
||||
if (newController != null && redstoneMode.isEnabled(worldObj, pos)) {
|
||||
onConnected(newController);
|
||||
onConnected(world, newController);
|
||||
}
|
||||
} else {
|
||||
if (newController == null) {
|
||||
onDisconnected();
|
||||
onDisconnected(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,41 +55,40 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
|
||||
searchController(worldObj);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
|
||||
|
||||
if (connected && !redstoneMode.isEnabled(worldObj, pos)) {
|
||||
onDisconnected();
|
||||
onDisconnected(worldObj);
|
||||
}
|
||||
|
||||
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void onConnected(TileController controller) {
|
||||
public void onConnected(World world, TileController controller) {
|
||||
this.controller = controller;
|
||||
this.connected = true;
|
||||
|
||||
if (worldObj.getBlockState(pos).getBlock() == block) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
|
||||
if (world.getBlockState(pos).getBlock() == block) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
|
||||
}
|
||||
|
||||
worldObj.notifyNeighborsOfStateChange(pos, block);
|
||||
world.notifyNeighborsOfStateChange(pos, block);
|
||||
|
||||
controller.addMachine(this);
|
||||
}
|
||||
|
||||
public void onDisconnected() {
|
||||
public void onDisconnected(World world) {
|
||||
this.connected = false;
|
||||
|
||||
if (worldObj.getBlockState(pos).getBlock() == block) {
|
||||
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
|
||||
if (world.getBlockState(pos).getBlock() == block) {
|
||||
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
|
||||
}
|
||||
|
||||
// I have no idea why this is needed
|
||||
if (this.controller != null) {
|
||||
this.controller.removeMachine(this);
|
||||
this.controller = null;
|
||||
}
|
||||
|
||||
worldObj.notifyNeighborsOfStateChange(pos, block);
|
||||
world.notifyNeighborsOfStateChange(pos, block);
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
|
@@ -6,6 +6,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerCrafter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
@@ -32,14 +33,14 @@ public class TileCrafter extends TileMachine implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
public void onDisconnected(World world) {
|
||||
for (ICraftingTask task : controller.getCraftingTasks()) {
|
||||
if (task.getPattern().getCrafter(worldObj) == this) {
|
||||
controller.cancelCraftingTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
super.onDisconnected();
|
||||
super.onDisconnected(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerSolderer;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
@@ -80,8 +81,8 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
super.onDisconnected();
|
||||
public void onDisconnected(World world) {
|
||||
super.onDisconnected(world);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
Reference in New Issue
Block a user