Merge pull request #4480 from AppliedEnergistics/mb-fixes

Fix more MultiBlock issues
This commit is contained in:
shartte
2020-07-19 17:31:06 +02:00
committed by GitHub
16 changed files with 199 additions and 274 deletions
@@ -47,5 +47,5 @@ public interface IAECluster {
*/
boolean isDestroyed();
Iterator<IGridHost> getTiles();
Iterator<? extends IGridHost> getTiles();
}
@@ -18,11 +18,11 @@
package appeng.me.cluster;
public interface IAEMultiBlock {
public interface IAEMultiBlock<Cluster extends IAECluster> {
void disconnect(boolean b);
IAECluster getCluster();
Cluster getCluster();
boolean isValid();
}
@@ -25,17 +25,21 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord;
import appeng.core.AELog;
import appeng.util.Platform;
public abstract class MBCalculator {
public abstract class MBCalculator<TTile extends IAEMultiBlock<TCluster>, TCluster extends IAECluster> {
/**
* To avoid recursive cluster rebuilds, we use a global field to prevent this
* from happening. This is set to the cluster that is currently causing a
* Multiblock modification.
*/
private static WeakReference<IAECluster> modificationInProgress = new WeakReference<>(null);
private final IAEMultiBlock target;
protected final TTile target;
public MBCalculator(final IAEMultiBlock t) {
public MBCalculator(final TTile t) {
this.target = t;
}
@@ -54,10 +58,10 @@ public abstract class MBCalculator {
return modificationInProgress.get() != null;
}
public void updateMultiblockAfterNeighborUpdate(final World world, final WorldCoord loc, BlockPos changedPos) {
public void updateMultiblockAfterNeighborUpdate(final World world, final BlockPos loc, BlockPos changedPos) {
boolean recheck;
IAECluster cluster = target.getCluster();
TCluster cluster = target.getCluster();
if (cluster != null) {
if (isWithinBounds(changedPos, cluster.getBoundsMin(), cluster.getBoundsMax())) {
// If the location is part of the current multiblock, always re-check
@@ -69,9 +73,8 @@ public abstract class MBCalculator {
}
} else {
// Always recheck if the tile is not part of a cluster, because the adjacent
// block could have
// previously been a valid tile, but in a wrong placement, or the other way
// around.
// block could have previously been a valid tile, but in a wrong placement,
// or the other way around.
recheck = true;
}
@@ -80,7 +83,7 @@ public abstract class MBCalculator {
}
}
public void calculateMultiblock(final World world, final WorldCoord loc) {
public void calculateMultiblock(final World world, final BlockPos loc) {
if (Platform.isClient() || isModificationInProgress()) {
return;
}
@@ -92,34 +95,31 @@ public abstract class MBCalculator {
}
try {
final WorldCoord min = loc.copy();
final WorldCoord max = loc.copy();
final BlockPos.Mutable min = new BlockPos.Mutable(loc);
final BlockPos.Mutable max = new BlockPos.Mutable(loc);
// find size of MB structure...
while (this.isValidTileAt(world, min.x - 1, min.y, min.z)) {
min.x--;
while (this.isValidTileAt(world, min.getX() - 1, min.getY(), min.getZ())) {
min.setX(min.getX() - 1);
}
while (this.isValidTileAt(world, min.x, min.y - 1, min.z)) {
min.y--;
while (this.isValidTileAt(world, min.getX(), min.getY() - 1, min.getZ())) {
min.setY(min.getY() - 1);
}
while (this.isValidTileAt(world, min.x, min.y, min.z - 1)) {
min.z--;
while (this.isValidTileAt(world, min.getX(), min.getY(), min.getZ() - 1)) {
min.setZ(min.getZ() - 1);
}
while (this.isValidTileAt(world, max.x + 1, max.y, max.z)) {
max.x++;
while (this.isValidTileAt(world, max.getX() + 1, max.getY(), max.getZ())) {
max.setX(max.getX() + 1);
}
while (this.isValidTileAt(world, max.x, max.y + 1, max.z)) {
max.y++;
while (this.isValidTileAt(world, max.getX(), max.getY() + 1, max.getZ())) {
max.setY(max.getY() + 1);
}
while (this.isValidTileAt(world, max.x, max.y, max.z + 1)) {
max.z++;
while (this.isValidTileAt(world, max.getX(), max.getY(), max.getZ() + 1)) {
max.setZ(max.getZ() + 1);
}
if (this.checkMultiblockScale(min, max)) {
if (this.verifyUnownedRegion(world, min, max)) {
IAECluster c = this.createCluster(world, min, max);
setModificationInProgress(c);
try {
if (!this.verifyInternalStructure(world, min, max)) {
this.disconnect();
@@ -131,16 +131,19 @@ public abstract class MBCalculator {
}
boolean updateGrid = false;
final IAECluster cluster = this.target.getCluster();
if (cluster == null) {
this.updateTiles(c, world, min, max);
TCluster cluster = this.target.getCluster();
if (cluster == null || !cluster.getBoundsMin().equals(min) || !cluster.getBoundsMax().equals(max)) {
cluster = this.createCluster(world, min, max);
setModificationInProgress(cluster);
// NOTE: The following will break existing clusters within the bounds
this.updateTiles(cluster, world, min, max);
updateGrid = true;
} else {
c = cluster;
setModificationInProgress(cluster);
}
c.updateStatus(updateGrid);
cluster.updateStatus(updateGrid);
return;
}
}
@@ -173,11 +176,12 @@ public abstract class MBCalculator {
*
* @return true if structure has correct dimensions or size
*/
public abstract boolean checkMultiblockScale(WorldCoord min, WorldCoord max);
public abstract boolean checkMultiblockScale(BlockPos min, BlockPos max);
private boolean verifyUnownedRegion(final World w, final WorldCoord min, final WorldCoord max) {
private boolean verifyUnownedRegion(final World w, final BlockPos min, final BlockPos max) {
for (final AEPartLocation side : AEPartLocation.SIDE_LOCATIONS) {
if (this.verifyUnownedRegionInner(w, min.x, min.y, min.z, max.x, max.y, max.z, side)) {
if (this.verifyUnownedRegionInner(w, min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ(),
side)) {
return false;
}
}
@@ -194,14 +198,16 @@ public abstract class MBCalculator {
*
* @return created cluster
*/
public abstract IAECluster createCluster(World w, WorldCoord min, WorldCoord max);
public abstract TCluster createCluster(World w, BlockPos min, BlockPos max);
public abstract boolean verifyInternalStructure(World world, WorldCoord min, WorldCoord max);
public abstract boolean verifyInternalStructure(World world, BlockPos min, BlockPos max);
/**
* disassembles the multi-block.
*/
public abstract void disconnect();
public void disconnect() {
this.target.disconnect(true);
}
/**
* configure the multi-block tiles, most of the important stuff is in here.
@@ -211,7 +217,7 @@ public abstract class MBCalculator {
* @param min min world coord
* @param max max world coord
*/
public abstract void updateTiles(IAECluster c, World w, WorldCoord min, WorldCoord max);
public abstract void updateTiles(TCluster c, World w, BlockPos min, BlockPos max);
/**
* check if the tile entities are correct for the structure.
@@ -253,14 +259,10 @@ public abstract class MBCalculator {
return false;
}
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
final TileEntity te = w.getTileEntity(new BlockPos(x, y, z));
if (this.isValidTile(te)) {
return true;
}
}
for (BlockPos p : BlockPos.getAllInBoxMutable(minX, minY, minZ, maxX, maxY, maxZ)) {
final TileEntity te = w.getTileEntity(p);
if (this.isValidTile(te)) {
return true;
}
}
@@ -29,32 +29,27 @@ import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.crafting.CraftingTileEntity;
public class CraftingCPUCalculator extends MBCalculator {
public class CraftingCPUCalculator extends MBCalculator<CraftingTileEntity, CraftingCPUCluster> {
private final CraftingTileEntity tqb;
public CraftingCPUCalculator(final IAEMultiBlock t) {
public CraftingCPUCalculator(final CraftingTileEntity t) {
super(t);
this.tqb = (CraftingTileEntity) t;
}
@Override
public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) {
if (max.x - min.x > 16) {
public boolean checkMultiblockScale(final BlockPos min, final BlockPos max) {
if (max.getX() - min.getX() > 16) {
return false;
}
if (max.y - min.y > 16) {
if (max.getY() - min.getY() > 16) {
return false;
}
if (max.z - min.z > 16) {
if (max.getZ() - min.getZ() > 16) {
return false;
}
@@ -62,27 +57,23 @@ public class CraftingCPUCalculator extends MBCalculator {
}
@Override
public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) {
public CraftingCPUCluster createCluster(final World w, final BlockPos min, final BlockPos max) {
return new CraftingCPUCluster(min, max);
}
@Override
public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) {
public boolean verifyInternalStructure(final World w, final BlockPos min, final BlockPos max) {
boolean storage = false;
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(new BlockPos(x, y, z));
for (BlockPos blockPos : BlockPos.getAllInBoxMutable(min, max)) {
final IAEMultiBlock<?> te = (IAEMultiBlock<?>) w.getTileEntity(blockPos);
if (!te.isValid()) {
return false;
}
if (te == null || !te.isValid()) {
return false;
}
if (!storage && te instanceof CraftingTileEntity) {
storage = ((CraftingTileEntity) te).getStorageBytes() > 0;
}
}
if (!storage && te instanceof CraftingTileEntity) {
storage = ((CraftingTileEntity) te).getStorageBytes() > 0;
}
}
@@ -90,27 +81,16 @@ public class CraftingCPUCalculator extends MBCalculator {
}
@Override
public void disconnect() {
this.tqb.disconnect(true);
}
@Override
public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) {
final CraftingCPUCluster c = (CraftingCPUCluster) cl;
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final CraftingTileEntity te = (CraftingTileEntity) w.getTileEntity(new BlockPos(x, y, z));
te.updateStatus(c);
c.addTile(te);
}
}
public void updateTiles(final CraftingCPUCluster c, final World w, final BlockPos min, final BlockPos max) {
for (BlockPos blockPos : BlockPos.getAllInBoxMutable(min, max)) {
final CraftingTileEntity te = (CraftingTileEntity) w.getTileEntity(blockPos);
te.updateStatus(c);
c.addTile(te);
}
c.done();
final Iterator<IGridHost> i = c.getTiles();
final Iterator<CraftingTileEntity> i = c.getTiles();
while (i.hasNext()) {
final IGridHost gh = i.next();
final IGridNode n = gh.getGridNode(AEPartLocation.INTERNAL);
@@ -18,12 +18,7 @@
package appeng.me.cluster.implementations;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import com.google.common.collect.ImmutableList;
@@ -45,14 +40,7 @@ import appeng.api.crafting.ICraftingHelper;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.CraftingItemList;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingMedium;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.crafting.*;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.networking.security.IActionSource;
@@ -62,15 +50,10 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.WorldCoord;
import appeng.container.ContainerNull;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.crafting.CraftBranchFailure;
import appeng.crafting.CraftingJob;
import appeng.crafting.CraftingLink;
import appeng.crafting.CraftingWatcher;
import appeng.crafting.MECraftingInventory;
import appeng.crafting.*;
import appeng.me.cache.CraftingGridCache;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.MBCalculator;
@@ -116,9 +99,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
private long startItemCount;
private long remainingItemCount;
public CraftingCPUCluster(final WorldCoord boundsMin, final WorldCoord boundsMax) {
this.boundsMin = boundsMin.getBlockPos();
this.boundsMax = boundsMax.getBlockPos();
public CraftingCPUCluster(final BlockPos boundsMin, final BlockPos boundsMax) {
this.boundsMin = boundsMin.toImmutable();
this.boundsMax = boundsMax.toImmutable();
}
@Override
@@ -175,7 +158,10 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
}
this.isDestroyed = true;
MBCalculator.setModificationInProgress(this);
boolean ownsModification = !MBCalculator.isModificationInProgress();
if (ownsModification) {
MBCalculator.setModificationInProgress(this);
}
try {
boolean posted = false;
@@ -192,13 +178,15 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
r.updateStatus(null);
}
} finally {
MBCalculator.setModificationInProgress(null);
if (ownsModification) {
MBCalculator.setModificationInProgress(null);
}
}
}
@Override
public Iterator<IGridHost> getTiles() {
return (Iterator) this.tiles.iterator();
public Iterator<CraftingTileEntity> getTiles() {
return this.tiles.iterator();
}
void addTile(final CraftingTileEntity te) {
@@ -25,31 +25,25 @@ import net.minecraft.world.World;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.util.WorldCoord;
import appeng.core.Api;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.qnb.QuantumBridgeTileEntity;
public class QuantumCalculator extends MBCalculator {
public class QuantumCalculator extends MBCalculator<QuantumBridgeTileEntity, QuantumCluster> {
private final QuantumBridgeTileEntity tqb;
public QuantumCalculator(final IAEMultiBlock t) {
public QuantumCalculator(final QuantumBridgeTileEntity t) {
super(t);
this.tqb = (QuantumBridgeTileEntity) t;
}
@Override
public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) {
public boolean checkMultiblockScale(final BlockPos min, final BlockPos max) {
if ((max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1) * (max.getZ() - min.getZ() + 1) == 9) {
final int ones = ((max.getX() - min.getX()) == 0 ? 1 : 0) + ((max.getY() - min.getY()) == 0 ? 1 : 0)
+ ((max.getZ() - min.getZ()) == 0 ? 1 : 0);
if ((max.x - min.x + 1) * (max.y - min.y + 1) * (max.z - min.z + 1) == 9) {
final int ones = ((max.x - min.x) == 0 ? 1 : 0) + ((max.y - min.y) == 0 ? 1 : 0)
+ ((max.z - min.z) == 0 ? 1 : 0);
final int threes = ((max.x - min.x) == 2 ? 1 : 0) + ((max.y - min.y) == 2 ? 1 : 0)
+ ((max.z - min.z) == 2 ? 1 : 0);
final int threes = ((max.getX() - min.getX()) == 2 ? 1 : 0) + ((max.getY() - min.getY()) == 2 ? 1 : 0)
+ ((max.getZ() - min.getZ()) == 2 ? 1 : 0);
return ones == 1 && threes == 2;
}
@@ -57,36 +51,31 @@ public class QuantumCalculator extends MBCalculator {
}
@Override
public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) {
public QuantumCluster createCluster(final World w, final BlockPos min, final BlockPos max) {
return new QuantumCluster(min, max);
}
@Override
public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) {
public boolean verifyInternalStructure(final World w, final BlockPos min, final BlockPos max) {
byte num = 0;
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final BlockPos p = new BlockPos(x, y, z);
final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(p);
for (BlockPos p : BlockPos.getAllInBoxMutable(min, max)) {
final IAEMultiBlock<?> te = (IAEMultiBlock<?>) w.getTileEntity(p);
if (!te.isValid()) {
return false;
}
if (te == null || !te.isValid()) {
return false;
}
num++;
final IBlocks blocks = Api.instance().definitions().blocks();
if (num == 5) {
if (!this.isBlockAtLocation(w, p, blocks.quantumLink())) {
return false;
}
} else {
if (!this.isBlockAtLocation(w, p, blocks.quantumRing())) {
return false;
}
}
num++;
final IBlocks blocks = Api.instance().definitions().blocks();
if (num == 5) {
if (!this.isBlockAtLocation(w, p, blocks.quantumLink())) {
return false;
}
} else {
if (!this.isBlockAtLocation(w, p, blocks.quantumRing())) {
return false;
}
}
}
@@ -94,39 +83,29 @@ public class QuantumCalculator extends MBCalculator {
}
@Override
public void disconnect() {
this.tqb.disconnect(true);
}
@Override
public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) {
public void updateTiles(final QuantumCluster c, final World w, final BlockPos min, final BlockPos max) {
byte num = 0;
byte ringNum = 0;
final QuantumCluster c = (QuantumCluster) cl;
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final QuantumBridgeTileEntity te = (QuantumBridgeTileEntity) w.getTileEntity(new BlockPos(x, y, z));
for (BlockPos p : BlockPos.getAllInBoxMutable(min, max)) {
final QuantumBridgeTileEntity te = (QuantumBridgeTileEntity) w.getTileEntity(p);
num++;
final byte flags;
if (num == 5) {
flags = num;
c.setCenter(te);
} else {
if (num == 1 || num == 3 || num == 7 || num == 9) {
flags = (byte) (this.tqb.getCorner() | num);
} else {
flags = num;
}
c.getRing()[ringNum] = te;
ringNum++;
}
te.updateStatus(c, flags, true);
num++;
final byte flags;
if (num == 5) {
flags = num;
c.setCenter(te);
} else {
if (num == 1 || num == 3 || num == 7 || num == 9) {
flags = (byte) (this.target.getCorner() | num);
} else {
flags = num;
}
c.getRing()[ringNum] = te;
ringNum++;
}
te.updateStatus(c, flags, true);
}
}
@@ -33,10 +33,8 @@ import appeng.api.events.LocatableEventAnnounce;
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
import appeng.api.exceptions.FailedConnectionException;
import appeng.api.features.ILocatable;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.util.AEPartLocation;
import appeng.api.util.WorldCoord;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.me.cache.helpers.ConnectionWrapper;
@@ -58,9 +56,9 @@ public class QuantumCluster implements ILocatable, IAECluster {
private long otherSide;
private QuantumBridgeTileEntity center;
public QuantumCluster(final WorldCoord min, final WorldCoord max) {
this.boundsMin = min.getBlockPos();
this.boundsMax = max.getBlockPos();
public QuantumCluster(final BlockPos min, final BlockPos max) {
this.boundsMin = min.toImmutable();
this.boundsMax = max.toImmutable();
this.setRing(new QuantumBridgeTileEntity[8]);
}
@@ -239,7 +237,7 @@ public class QuantumCluster implements ILocatable, IAECluster {
}
@Override
public Iterator<IGridHost> getTiles() {
public Iterator<QuantumBridgeTileEntity> getTiles() {
return new ChainedIterator<>(this.getRing()[0], this.getRing()[1], this.getRing()[2], this.getRing()[3],
this.getRing()[4], this.getRing()[5], this.getRing()[6], this.getRing()[7], this.center);
}
@@ -22,45 +22,36 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.util.WorldCoord;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.IAEMultiBlock;
import appeng.me.cluster.MBCalculator;
import appeng.tile.spatial.SpatialPylonTileEntity;
public class SpatialPylonCalculator extends MBCalculator {
public class SpatialPylonCalculator extends MBCalculator<SpatialPylonTileEntity, SpatialPylonCluster> {
private final SpatialPylonTileEntity tqb;
public SpatialPylonCalculator(final IAEMultiBlock t) {
public SpatialPylonCalculator(final SpatialPylonTileEntity t) {
super(t);
this.tqb = (SpatialPylonTileEntity) t;
}
@Override
public boolean checkMultiblockScale(final WorldCoord min, final WorldCoord max) {
return (min.x == max.x && min.y == max.y && min.z != max.z)
|| (min.x == max.x && min.y != max.y && min.z == max.z)
|| (min.x != max.x && min.y == max.y && min.z == max.z);
public boolean checkMultiblockScale(final BlockPos min, final BlockPos max) {
return (min.getX() == max.getX() && min.getY() == max.getY() && min.getZ() != max.getZ())
|| (min.getX() == max.getX() && min.getY() != max.getY() && min.getZ() == max.getZ())
|| (min.getX() != max.getX() && min.getY() == max.getY() && min.getZ() == max.getZ());
}
@Override
public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) {
return new SpatialPylonCluster(w, min.getBlockPos(), max.getBlockPos());
public SpatialPylonCluster createCluster(final World w, final BlockPos min, final BlockPos max) {
return new SpatialPylonCluster(w, min, max);
}
@Override
public boolean verifyInternalStructure(final World w, final WorldCoord min, final WorldCoord max) {
public boolean verifyInternalStructure(final World w, final BlockPos min, final BlockPos max) {
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity(new BlockPos(x, y, z));
for (BlockPos p : BlockPos.getAllInBoxMutable(min, max)) {
final IAEMultiBlock<?> te = (IAEMultiBlock<?>) w.getTileEntity(p);
if (!te.isValid()) {
return false;
}
}
if (te == null || !te.isValid()) {
return false;
}
}
@@ -68,22 +59,11 @@ public class SpatialPylonCalculator extends MBCalculator {
}
@Override
public void disconnect() {
this.tqb.disconnect(true);
}
@Override
public void updateTiles(final IAECluster cl, final World w, final WorldCoord min, final WorldCoord max) {
final SpatialPylonCluster c = (SpatialPylonCluster) cl;
for (int x = min.x; x <= max.x; x++) {
for (int y = min.y; y <= max.y; y++) {
for (int z = min.z; z <= max.z; z++) {
final SpatialPylonTileEntity te = (SpatialPylonTileEntity) w.getTileEntity(new BlockPos(x, y, z));
te.updateStatus(c);
c.getLine().add((te));
}
}
public void updateTiles(final SpatialPylonCluster c, final World w, final BlockPos min, final BlockPos max) {
for (BlockPos p : BlockPos.getAllInBoxMutable(min, max)) {
final SpatialPylonTileEntity te = (SpatialPylonTileEntity) w.getTileEntity(p);
te.updateStatus(c);
c.getLine().add(te);
}
}
@@ -25,7 +25,6 @@ import java.util.List;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.networking.IGridHost;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.MBCalculator;
import appeng.tile.spatial.SpatialPylonTileEntity;
@@ -88,8 +87,8 @@ public class SpatialPylonCluster implements IAECluster {
}
@Override
public Iterator<IGridHost> getTiles() {
return (Iterator) this.getLine().iterator();
public Iterator<SpatialPylonTileEntity> getTiles() {
return this.getLine().iterator();
}
public int tileCount() {
@@ -41,11 +41,10 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
if (this.getCluster() == null) {
return new ChainedIterator<>();
}
return new ProxyNodeIterator(this.getCluster().getTiles());
}
private IAECluster getCluster() {
return ((IAEMultiBlock) this.getMachine()).getCluster();
return ((IAEMultiBlock<?>) this.getMachine()).getCluster();
}
}