Correctly save stuff, should work for Funky Locomotion integration
This commit is contained in:
@@ -80,7 +80,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(tile instanceof INetworkNode)) {
|
if (!(tile instanceof INetworkNode) || (tile != null && tile.isInvalid())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,35 +270,13 @@ public class BlockCable extends BlockCoverable {
|
|||||||
if (getPlacementType() != null) {
|
if (getPlacementType() != null) {
|
||||||
((TileBase) world.getTileEntity(pos)).setDirection(state.getValue(DIRECTION));
|
((TileBase) world.getTileEntity(pos)).setDirection(state.getValue(DIRECTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
attemptConnect(world, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attemptConnect(World world, BlockPos pos) {
|
|
||||||
if (!world.isRemote) {
|
|
||||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
|
||||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
|
||||||
((TileNode) tile).getNetwork().getNodeGraph().rebuild();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||||
INetworkMaster network = null;
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
if (tile instanceof TileNode) {
|
|
||||||
network = ((TileNode) tile).getNetwork();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) {
|
if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) {
|
||||||
IItemHandler handler = ((TileBase) tile).getDrops();
|
IItemHandler handler = ((TileBase) tile).getDrops();
|
||||||
|
|
||||||
@@ -311,10 +289,6 @@ public class BlockCable extends BlockCoverable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.breakBlock(world, pos, state);
|
super.breakBlock(world, pos, state);
|
||||||
|
|
||||||
if (network != null) {
|
|
||||||
network.getNodeGraph().rebuild();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -102,15 +102,6 @@ public class BlockController extends BlockBase {
|
|||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
|
||||||
if (!world.isRemote) {
|
|
||||||
((TileController) world.getTileEntity(pos)).onDestroyed();
|
|
||||||
}
|
|
||||||
|
|
||||||
super.breakBlock(world, pos, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
|
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
package com.raoulvdberge.refinedstorage.block;
|
package com.raoulvdberge.refinedstorage.block;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public abstract class BlockNode extends BlockBase {
|
public abstract class BlockNode extends BlockBase {
|
||||||
public static final PropertyBool CONNECTED = PropertyBool.create("connected");
|
public static final PropertyBool CONNECTED = PropertyBool.create("connected");
|
||||||
@@ -50,42 +44,6 @@ public abstract class BlockNode extends BlockBase {
|
|||||||
return super.getActualState(state, world, pos);
|
return super.getActualState(state, world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
|
||||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
|
||||||
((TileNode) tile).getNetwork().getNodeGraph().rebuild();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
|
||||||
INetworkMaster network = null;
|
|
||||||
|
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
|
|
||||||
if (tile instanceof TileNode) {
|
|
||||||
network = ((TileNode) tile).getNetwork();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.breakBlock(world, pos, state);
|
|
||||||
|
|
||||||
if (network != null) {
|
|
||||||
network.getNodeGraph().rebuild();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasConnectivityState() {
|
public boolean hasConnectivityState() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
super.invalidate();
|
super.invalidate();
|
||||||
|
|
||||||
energyEU.invalidate();
|
energyEU.invalidate();
|
||||||
|
|
||||||
|
if (!worldObj.isRemote) {
|
||||||
|
onBreak();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -351,7 +355,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
energyEU.onChunkUnload();
|
energyEU.onChunkUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroyed() {
|
public void onBreak() {
|
||||||
nodeGraph.disconnectAll();
|
nodeGraph.disconnectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,13 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
onBreak();
|
||||||
|
|
||||||
|
super.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||||
super.onConnectionChange(network, state);
|
super.onConnectionChange(network, state);
|
||||||
|
|||||||
@@ -613,4 +613,11 @@ public class TileDiskManipulator extends TileNode implements IComparable, IFilte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
onBreak();
|
||||||
|
|
||||||
|
super.invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,13 @@ public class TileFluidStorage extends TileNode implements IFluidStorageProvider,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
onBreak();
|
||||||
|
|
||||||
|
super.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||||
super.onConnectionChange(network, state);
|
super.onConnectionChange(network, state);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
|
||||||
import mcmultipart.capabilities.ISlottedCapabilityProvider;
|
import mcmultipart.capabilities.ISlottedCapabilityProvider;
|
||||||
import mcmultipart.capabilities.MultipartCapabilityHelper;
|
import mcmultipart.capabilities.MultipartCapabilityHelper;
|
||||||
import mcmultipart.microblock.IMicroblock;
|
import mcmultipart.microblock.IMicroblock;
|
||||||
@@ -72,7 +71,7 @@ public abstract class TileMultipartNode extends TileNode implements IMicroblockC
|
|||||||
if (network != null) {
|
if (network != null) {
|
||||||
network.getNodeGraph().rebuild();
|
network.getNodeGraph().rebuild();
|
||||||
} else if (worldObj != null) {
|
} else if (worldObj != null) {
|
||||||
RSBlocks.CABLE.attemptConnect(worldObj, pos);
|
rebuildNearbyGraph();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
protected INetworkMaster network;
|
protected INetworkMaster network;
|
||||||
|
|
||||||
protected boolean rebuildOnUpdateChange;
|
protected boolean rebuildOnUpdateChange;
|
||||||
|
private boolean rebuildNearbyGraph;
|
||||||
|
|
||||||
public TileNode() {
|
public TileNode() {
|
||||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||||
@@ -57,6 +58,10 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
}
|
}
|
||||||
|
|
||||||
networkPos = null;
|
networkPos = null;
|
||||||
|
} else if (rebuildNearbyGraph) {
|
||||||
|
rebuildNearbyGraph = false;
|
||||||
|
|
||||||
|
rebuildNearbyGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update != canUpdate() && network != null) {
|
if (update != canUpdate() && network != null) {
|
||||||
@@ -83,6 +88,18 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void rebuildNearbyGraph() {
|
||||||
|
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||||
|
TileEntity tile = worldObj.getTileEntity(pos.offset(facing));
|
||||||
|
|
||||||
|
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
||||||
|
((TileNode) tile).getNetwork().getNodeGraph().rebuild();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected(INetworkMaster network) {
|
public void onConnected(INetworkMaster network) {
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
@@ -201,4 +218,20 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
public boolean hasConnectivityState() {
|
public boolean hasConnectivityState() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
super.invalidate();
|
||||||
|
|
||||||
|
if (!worldObj.isRemote && network != null) {
|
||||||
|
network.getNodeGraph().rebuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate() {
|
||||||
|
super.validate();
|
||||||
|
|
||||||
|
rebuildNearbyGraph = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,13 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
onBreak();
|
||||||
|
|
||||||
|
super.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||||
super.onConnectionChange(network, state);
|
super.onConnectionChange(network, state);
|
||||||
|
|||||||
Reference in New Issue
Block a user