Force cluster-rebuilds on the first detected change, if their bounds do not match.
Also use a client-side method to update connected textures for crafting cubes if two previously distinct clusters are connected. Refactored MBCalculator to use generics for type checks and remove more casts.
This commit is contained in:
@@ -18,11 +18,7 @@
|
||||
|
||||
package appeng.tile.crafting;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -35,7 +31,6 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
@@ -52,7 +47,6 @@ import appeng.api.util.WorldCoord;
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock;
|
||||
import appeng.block.crafting.AbstractCraftingUnitBlock.CraftingUnitType;
|
||||
import appeng.core.Api;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCalculator;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
@@ -61,7 +55,8 @@ import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.grid.AENetworkTileEntity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiBlock, IPowerChannelState {
|
||||
public class CraftingTileEntity extends AENetworkTileEntity
|
||||
implements IAEMultiBlock<CraftingCPUCluster>, IPowerChannelState {
|
||||
|
||||
private final CraftingCPUCalculator calc = new CraftingCPUCalculator(this);
|
||||
private CompoundNBT previousState = null;
|
||||
@@ -112,7 +107,7 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
|
||||
return false;
|
||||
}
|
||||
|
||||
final AbstractCraftingUnitBlock unit = (AbstractCraftingUnitBlock) this.world.getBlockState(this.pos)
|
||||
final AbstractCraftingUnitBlock<?> unit = (AbstractCraftingUnitBlock<?>) this.world.getBlockState(this.pos)
|
||||
.getBlock();
|
||||
return unit.type == CraftingUnitType.ACCELERATOR;
|
||||
}
|
||||
@@ -121,11 +116,11 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.getProxy().setVisualRepresentation(this.getItemFromTile(this));
|
||||
this.calc.calculateMultiblock(world, getLocation());
|
||||
this.calc.calculateMultiblock(world, pos);
|
||||
}
|
||||
|
||||
public void updateMultiBlock(BlockPos changedPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), changedPos);
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, pos, changedPos);
|
||||
}
|
||||
|
||||
public void updateStatus(final CraftingCPUCluster c) {
|
||||
@@ -160,7 +155,7 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
|
||||
// Not using flag 2 here (only send to clients, prevent block update) will cause
|
||||
// infinite loops
|
||||
// In case there is an inconsistency in the crafting clusters.
|
||||
this.world.setBlockState(this.pos, newState, Constants.BlockFlags.BLOCK_UPDATE);
|
||||
this.world.setBlockState(this.pos, newState, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +209,7 @@ public class CraftingTileEntity extends AENetworkTileEntity implements IAEMultiB
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAECluster getCluster() {
|
||||
public CraftingCPUCluster getCluster() {
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.block.qnb.QnbFormedState;
|
||||
import appeng.core.Api;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.QuantumCalculator;
|
||||
import appeng.me.cluster.implementations.QuantumCluster;
|
||||
@@ -57,7 +56,8 @@ import appeng.tile.grid.AENetworkInvTileEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements IAEMultiBlock, ITickableTileEntity {
|
||||
public class QuantumBridgeTileEntity extends AENetworkInvTileEntity
|
||||
implements IAEMultiBlock<QuantumCluster>, ITickableTileEntity {
|
||||
|
||||
public static final ModelProperty<QnbFormedState> FORMED_STATE = new ModelProperty<>();
|
||||
|
||||
@@ -191,7 +191,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAECluster getCluster() {
|
||||
public QuantumCluster getCluster() {
|
||||
return this.cluster;
|
||||
}
|
||||
|
||||
@@ -210,11 +210,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
|
||||
}
|
||||
|
||||
if (this.isCorner() || this.isCenter()) {
|
||||
final EnumSet<Direction> sides = EnumSet.noneOf(Direction.class);
|
||||
for (final Direction dir : this.getAdjacentQuantumBridges()) {
|
||||
sides.add(dir);
|
||||
}
|
||||
|
||||
EnumSet<Direction> sides = EnumSet.copyOf(this.getAdjacentQuantumBridges());
|
||||
this.getProxy().setValidSides(sides);
|
||||
} else {
|
||||
this.getProxy().setValidSides(EnumSet.allOf(Direction.class));
|
||||
@@ -274,7 +270,7 @@ public class QuantumBridgeTileEntity extends AENetworkInvTileEntity implements I
|
||||
}
|
||||
|
||||
public void neighborUpdate(BlockPos fromPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), fromPos);
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.pos, fromPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.grid.AENetworkTileEntity;
|
||||
|
||||
public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMultiBlock {
|
||||
public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMultiBlock<SpatialPylonCluster> {
|
||||
|
||||
public static final ModelProperty<Integer> STATE = new ModelProperty<>(value -> {
|
||||
// The lower 6 bits are used
|
||||
@@ -88,7 +88,7 @@ public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMu
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.calc.calculateMultiblock(world, getLocation());
|
||||
this.calc.calculateMultiblock(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +98,7 @@ public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMu
|
||||
}
|
||||
|
||||
public void neighborChanged(BlockPos changedPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), changedPos);
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, pos, changedPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,9 +131,9 @@ public class SpatialPylonTileEntity extends AENetworkTileEntity implements IAEMu
|
||||
this.displayBits = 0;
|
||||
|
||||
if (this.cluster != null) {
|
||||
if (this.cluster.getBoundsMin().equals(this.getLocation())) {
|
||||
if (this.cluster.getBoundsMin().equals(this.pos)) {
|
||||
this.displayBits = DISPLAY_END_MIN;
|
||||
} else if (this.cluster.getBoundsMax().equals(this.getLocation())) {
|
||||
} else if (this.cluster.getBoundsMax().equals(this.pos)) {
|
||||
this.displayBits = DISPLAY_END_MAX;
|
||||
} else {
|
||||
this.displayBits = DISPLAY_MIDDLE;
|
||||
|
||||
Reference in New Issue
Block a user