private void switchSourceIfNeeded() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); if (meta > 5) switchSource(); else { TileEntity tile = container.getTile(Orientations.values()[meta]); if (!isInput(tile)) switchSource(); } }
public void switchSource() { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int newMeta = 6; for (int i = meta + 1; i <= meta + 6; ++i) { Orientations o = Orientations.values()[i % 6]; Block block = Block.blocksList[container.getBlockId(o)]; TileEntity tile = container.getTile(o); if (isInput(tile)) if (!isExcludedFromExtraction(block)) { newMeta = o.ordinal(); break; } } if (newMeta != meta) { worldObj.setBlockMetadata(xCoord, yCoord, zCoord, newMeta); worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); } }