Very unstable improved machine searching part3

This commit is contained in:
Raoul Van den Berge
2016-05-13 22:26:08 +02:00
parent 136e2564f1
commit bc72c25af9
4 changed files with 17 additions and 16 deletions

View File

@@ -5,8 +5,6 @@ import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -51,15 +49,6 @@ public abstract class BlockMachine extends BlockBase {
super.breakBlock(world, pos, state);
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, player, stack);
if (!world.isRemote) {
((TileMachine) world.getTileEntity(pos)).searchController();
}
}
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) {
super.onNeighborBlockChange(world, pos, state, neighborBlock);

View File

@@ -382,7 +382,7 @@ public class CommonProxy {
GameRegistry.addShapelessRecipe(disk,
new ItemStack(RefinedStorageItems.STORAGE_HOUSING),
new ItemStack(RefinedStorageItems.STORAGE_PART, type, type)
new ItemStack(RefinedStorageItems.STORAGE_PART, 1, type)
);
}

View File

@@ -80,6 +80,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
}
public void removeMachine(TileMachine machine) {
System.out.println("Added for removal!");
machinesToRemove.add(machine.getPos());
}
@@ -92,8 +93,11 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
machinesToAdd.clear();
for (BlockPos pos : machinesToRemove) {
System.out.println("ToRemove:" + pos.getX() + "," + pos.getY() + "," + pos.getZ());
for (TileMachine machine : machines) {
if (machine.getPos().getX() == pos.getX() && machine.getPos().getY() == pos.getY() && machine.getPos().getZ() == pos.getZ()) {
System.out.println("Machine:" + machine.getPos().getX() + "," + machine.getPos().getY() + "," + machine.getPos().getZ());
if (machine.getPos().equals(pos)) {
System.out.println("Found! Removing");
machines.remove(machine);
break;
}

View File

@@ -1,6 +1,7 @@
package refinedstorage.tile;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import refinedstorage.block.BlockMachine;
@@ -14,6 +15,7 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
protected boolean connected = false;
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
protected TileController controller;
private Block block;
private Set<String> visited = new HashSet<String>();
@@ -41,7 +43,9 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
public void onLoad() {
super.onLoad();
if (!worldObj.isRemote && !connected) {
if (!worldObj.isRemote) {
block = worldObj.getBlockState(pos).getBlock();
searchController();
}
}
@@ -49,7 +53,9 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
public void onConnected() {
connected = true;
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
if (worldObj.getBlockState(pos).getBlock() == block) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, true));
}
controller.addMachine(this);
}
@@ -57,7 +63,9 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
public void onDisconnected() {
connected = false;
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
if (worldObj.getBlockState(pos).getBlock() == block) {
worldObj.setBlockState(pos, worldObj.getBlockState(pos).withProperty(BlockMachine.CONNECTED, false));
}
controller.removeMachine(this);
}