Bugfixes 2

This commit is contained in:
Raoul Van den Berge
2016-05-14 18:11:28 +02:00
parent 38f1209f11
commit 0e05fc47f2
7 changed files with 26 additions and 29 deletions

View File

@@ -292,12 +292,12 @@ public class RefinedStorageUtils {
} }
public static void sendToAllAround(World world, BlockPos pos, IMessage message) { 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); RefinedStorage.NETWORK.sendToAllAround(message, target);
} }
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), 2 | 4); world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
} }
} }

View File

@@ -42,7 +42,7 @@ public abstract class BlockMachine extends BlockBase {
TileMachine machine = (TileMachine) world.getTileEntity(pos); TileMachine machine = (TileMachine) world.getTileEntity(pos);
if (machine.isConnected()) { if (machine.isConnected()) {
machine.onDisconnected(); machine.onDisconnected(world);
} }
} }

View File

@@ -228,7 +228,7 @@ public class TileController extends TileBase implements IEnergyReceiver, ISynchr
private void disconnectAll() { private void disconnectAll() {
for (TileMachine machine : machines) { for (TileMachine machine : machines) {
machine.onDisconnected(); machine.onDisconnected(worldObj);
} }
machines.clear(); machines.clear();

View File

@@ -5,6 +5,7 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import refinedstorage.RefinedStorageBlocks; import refinedstorage.RefinedStorageBlocks;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
import refinedstorage.container.ContainerDetector; import refinedstorage.container.ContainerDetector;
@@ -32,8 +33,8 @@ public class TileDetector extends TileMachine implements ICompareConfig {
private boolean powered = false; private boolean powered = false;
@Override @Override
public void onDisconnected() { public void onDisconnected(World world) {
super.onDisconnected(); super.onDisconnected(world);
powered = false; powered = false;
} }

View File

@@ -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 // 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. // this method is called and at that point in time worldObj is not set yet.
public void searchController(World world) { 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);
if (controller == null) { if (controller == null) {
if (newController != null && redstoneMode.isEnabled(worldObj, pos)) { if (newController != null && redstoneMode.isEnabled(worldObj, pos)) {
onConnected(newController); onConnected(world, newController);
} }
} else { } else {
if (newController == null) { if (newController == null) {
onDisconnected(); onDisconnected(world);
} }
} }
} }
@@ -60,41 +55,40 @@ public abstract class TileMachine extends TileBase implements ISynchronizedConta
searchController(worldObj); searchController(worldObj);
} }
RefinedStorageUtils.sendToAllAround(worldObj, pos, new MessageMachineConnectedUpdate(this));
if (connected && !redstoneMode.isEnabled(worldObj, pos)) { 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.controller = controller;
this.connected = true; this.connected = true;
if (worldObj.getBlockState(pos).getBlock() == block) { if (world.getBlockState(pos).getBlock() == block) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true)); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
} }
worldObj.notifyNeighborsOfStateChange(pos, block); world.notifyNeighborsOfStateChange(pos, block);
controller.addMachine(this); controller.addMachine(this);
} }
public void onDisconnected() { public void onDisconnected(World world) {
this.connected = false; this.connected = false;
if (worldObj.getBlockState(pos).getBlock() == block) { if (world.getBlockState(pos).getBlock() == block) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false)); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
} }
// I have no idea why this is needed
if (this.controller != null) { if (this.controller != null) {
this.controller.removeMachine(this); this.controller.removeMachine(this);
this.controller = null; this.controller = null;
} }
worldObj.notifyNeighborsOfStateChange(pos, block); world.notifyNeighborsOfStateChange(pos, block);
} }
public boolean isConnected() { public boolean isConnected() {

View File

@@ -6,6 +6,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
import refinedstorage.container.ContainerCrafter; import refinedstorage.container.ContainerCrafter;
import refinedstorage.inventory.InventorySimple; import refinedstorage.inventory.InventorySimple;
@@ -32,14 +33,14 @@ public class TileCrafter extends TileMachine implements IInventory {
} }
@Override @Override
public void onDisconnected() { public void onDisconnected(World world) {
for (ICraftingTask task : controller.getCraftingTasks()) { for (ICraftingTask task : controller.getCraftingTasks()) {
if (task.getPattern().getCrafter(worldObj) == this) { if (task.getPattern().getCrafter(worldObj) == this) {
controller.cancelCraftingTask(task); controller.cancelCraftingTask(task);
} }
} }
super.onDisconnected(); super.onDisconnected(world);
} }
@Override @Override

View File

@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
import refinedstorage.RefinedStorageUtils; import refinedstorage.RefinedStorageUtils;
import refinedstorage.container.ContainerSolderer; import refinedstorage.container.ContainerSolderer;
import refinedstorage.inventory.InventorySimple; import refinedstorage.inventory.InventorySimple;
@@ -80,8 +81,8 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
} }
@Override @Override
public void onDisconnected() { public void onDisconnected(World world) {
super.onDisconnected(); super.onDisconnected(world);
reset(); reset();
} }