Fix crash
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package refinedstorage.tile;
|
package refinedstorage.tile;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
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 refinedstorage.block.BlockMachine;
|
import refinedstorage.block.BlockMachine;
|
||||||
@@ -12,8 +13,10 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
|
|||||||
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||||
protected TileController controller;
|
protected TileController controller;
|
||||||
|
|
||||||
|
private Block machineBlock;
|
||||||
|
|
||||||
public void onConnected(TileController controller) {
|
public void onConnected(TileController controller) {
|
||||||
if (worldObj != null && worldObj.getBlockState(pos).getBlock() == getBlockType()) {
|
if (worldObj != null && worldObj.getBlockState(pos).getBlock() == machineBlock) {
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
@@ -24,7 +27,7 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
if (worldObj != null && worldObj.getBlockState(pos).getBlock() == getBlockType()) {
|
if (worldObj != null && worldObj.getBlockState(pos).getBlock() == machineBlock) {
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
@@ -40,9 +43,18 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
|
if (worldObj == null) {
|
||||||
|
super.update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ticks == 0) {
|
||||||
|
machineBlock = worldObj.getBlockState(pos).getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if (worldObj != null && !worldObj.isRemote && isConnected()) {
|
if (!worldObj.isRemote && isConnected()) {
|
||||||
updateMachine();
|
updateMachine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user