Merge remote-tracking branch 'origin/master' into fabric-1.16
# Conflicts: # src/main/java/appeng/block/spatial/SpatialPylonBlock.java # src/main/java/appeng/client/render/spatial/SpatialPylonBakedModel.java # src/main/java/appeng/core/AppEng.java # src/main/java/appeng/hooks/TickHandler.java # src/main/java/appeng/me/cluster/MBCalculator.java # src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java # src/main/java/appeng/me/cluster/implementations/QuantumCluster.java # src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java # src/main/java/appeng/me/helpers/AENetworkProxy.java # src/main/java/appeng/tile/networking/CableBusBlockEntity.java # src/main/java/appeng/tile/networking/DenseEnergyCellBlockEntity.java # src/main/java/appeng/tile/qnb/QuantumBridgeBlockEntity.java # src/main/java/appeng/tile/spatial/SpatialPylonBlockEntity.java # src/main/java/appeng/util/Platform.java
This commit is contained in:
@@ -59,7 +59,7 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingBlockEntity> e
|
||||
final BlockPos fromPos, boolean isMoving) {
|
||||
final CraftingBlockEntity cp = this.getBlockEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
cp.updateMultiBlock(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeBloc
|
||||
boolean isMoving) {
|
||||
final QuantumBridgeBlockEntity bridge = this.getBlockEntity(world, pos);
|
||||
if (bridge != null) {
|
||||
bridge.neighborUpdate();
|
||||
bridge.neighborUpdate(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonBlockEntity>
|
||||
boolean isMoving) {
|
||||
final SpatialPylonBlockEntity tsp = this.getBlockEntity(world, pos);
|
||||
if (tsp != null) {
|
||||
tsp.neighborUpdate();
|
||||
tsp.neighborUpdate(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ class SpatialPylonBakedModel implements BakedModel, FabricBakedModel {
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,6 +57,6 @@ public class PaintedEntityPacket extends BasePacket {
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
final PlayerColor pc = new PlayerColor(this.entityId, this.myColor, this.ticks);
|
||||
TickHandler.INSTANCE.getPlayerColors().put(this.entityId, pc);
|
||||
TickHandler.instance().getPlayerColors().put(this.entityId, pc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class CraftingJob implements Runnable, ICraftingJob {
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
TickHandler.INSTANCE.registerCraftingSimulation(this.world, this);
|
||||
TickHandler.instance().registerCraftingSimulation(this.world, this);
|
||||
this.handlePausing();
|
||||
|
||||
final Stopwatch timer = Stopwatch.createStarted();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DebugCardItem extends AEBaseItem implements AEToolItem {
|
||||
int grids = 0;
|
||||
int totalNodes = 0;
|
||||
|
||||
for (final Grid g : TickHandler.INSTANCE.getGridList()) {
|
||||
for (final Grid g : TickHandler.instance().getGridList()) {
|
||||
grids++;
|
||||
totalNodes += g.getNodes().size();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,37 @@
|
||||
|
||||
package appeng.hooks;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.WorldTickEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.DistExecutor.SafeRunnable;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
@@ -41,10 +72,10 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TickHandler {
|
||||
|
||||
public static final TickHandler INSTANCE = new TickHandler();
|
||||
private static final TickHandler INSTANCE = new TickHandler();
|
||||
private final Queue<IWorldCallable<?>> serverQueue = new ArrayDeque<>();
|
||||
private final Multimap<World, CraftingJob> craftingJobs = LinkedListMultimap.create();
|
||||
private final WeakHashMap<WorldAccess, Queue<IWorldCallable<?>>> callQueue = new WeakHashMap<>();
|
||||
private final Map<WorldAccess, Queue<IWorldCallable<?>>> callQueue = new WeakHashMap<>();
|
||||
private final HandlerRep server = new HandlerRep();
|
||||
private final HandlerRep client = new HandlerRep();
|
||||
private final HashMap<Integer, PlayerColor> srvPlayerColors = new HashMap<>();
|
||||
@@ -57,7 +88,29 @@ public class TickHandler {
|
||||
|
||||
}
|
||||
|
||||
public HashMap<Integer, PlayerColor> getPlayerColors() {
|
||||
public static TickHandler instance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void setup(IEventBus eventBus) {
|
||||
eventBus.addListener(INSTANCE::onServerTick);
|
||||
eventBus.addListener(INSTANCE::onWorldTick);
|
||||
eventBus.addListener(INSTANCE::onUnloadWorld);
|
||||
|
||||
// DistExecutor does not like functional interfaces
|
||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable() {
|
||||
|
||||
private static final long serialVersionUID = 5221919736953944125L;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
eventBus.addListener(INSTANCE::onClientTick);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<Integer, PlayerColor> getPlayerColors() {
|
||||
return this.srvPlayerColors;
|
||||
}
|
||||
|
||||
@@ -77,8 +130,8 @@ public class TickHandler {
|
||||
}
|
||||
|
||||
public void addInit(final AEBaseBlockEntity tile) {
|
||||
if (Platform.isServer()) // for no there is no reason to care about this on the client...
|
||||
{
|
||||
// for no there is no reason to care about this on the client...
|
||||
if (Platform.isServer()) {
|
||||
this.getRepo().tiles.add(tile);
|
||||
}
|
||||
}
|
||||
@@ -91,15 +144,15 @@ public class TickHandler {
|
||||
}
|
||||
|
||||
public void addNetwork(final Grid grid) {
|
||||
if (Platform.isServer()) // for no there is no reason to care about this on the client...
|
||||
{
|
||||
// for no there is no reason to care about this on the client...
|
||||
if (Platform.isServer()) {
|
||||
this.getRepo().addNetwork(grid);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNetwork(final Grid grid) {
|
||||
if (Platform.isServer()) // for no there is no reason to care about this on the client...
|
||||
{
|
||||
// for no there is no reason to care about this on the client...
|
||||
if (Platform.isServer()) {
|
||||
this.getRepo().removeNetwork(grid);
|
||||
}
|
||||
}
|
||||
@@ -142,9 +195,10 @@ public class TickHandler {
|
||||
synchronized (this.craftingJobs) {
|
||||
final Collection<CraftingJob> jobSet = this.craftingJobs.get(world);
|
||||
if (!jobSet.isEmpty()) {
|
||||
final int simTime = Math.max(1,
|
||||
AEConfig.instance().getCraftingCalculationTimePerTick() / jobSet.size());
|
||||
final Iterator<CraftingJob> i = jobSet.iterator();
|
||||
final int jobSize = jobSet.size();
|
||||
final int microSecondsPerTick = AEConfig.instance().getCraftingCalculationTimePerTick() * 1000;
|
||||
final int simTime = Math.max(1, microSecondsPerTick / jobSize);
|
||||
final Iterator<CraftingJob> i = jobSet.iterator();
|
||||
while (i.hasNext()) {
|
||||
final CraftingJob cj = i.next();
|
||||
if (!cj.simulateFor(simTime)) {
|
||||
@@ -176,8 +230,15 @@ public class TickHandler {
|
||||
this.processQueue(this.serverQueue, null);
|
||||
}
|
||||
|
||||
protected void tickColors(final HashMap<Integer, PlayerColor> playerSet) {
|
||||
public void registerCraftingSimulation(final World world, final CraftingJob craftingJob) {
|
||||
synchronized (this.craftingJobs) {
|
||||
this.craftingJobs.put(world, craftingJob);
|
||||
}
|
||||
}
|
||||
|
||||
protected void tickColors(final Map<Integer, PlayerColor> playerSet) {
|
||||
final Iterator<PlayerColor> i = playerSet.values().iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
final PlayerColor pc = i.next();
|
||||
if (pc.ticksLeft <= 0) {
|
||||
@@ -206,16 +267,6 @@ public class TickHandler {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
// long time = sw.elapsed( TimeUnit.MILLISECONDS );
|
||||
// if ( time > 0 )
|
||||
// AELog.info( "processQueue Time: " + time + "ms" );
|
||||
}
|
||||
|
||||
public void registerCraftingSimulation(final World world, final CraftingJob craftingJob) {
|
||||
synchronized (this.craftingJobs) {
|
||||
this.craftingJobs.put(world, craftingJob);
|
||||
}
|
||||
}
|
||||
|
||||
private static class HandlerRep {
|
||||
|
||||
@@ -245,7 +245,7 @@ public class MatterCannonItem extends AEBasePoweredItem implements IStorageCell<
|
||||
|
||||
final int id = entityHit.getEntityId();
|
||||
final PlayerColor marker = new PlayerColor(id, col, 20 * 30);
|
||||
TickHandler.INSTANCE.getPlayerColors().put(id, marker);
|
||||
TickHandler.instance().getPlayerColors().put(id, marker);
|
||||
|
||||
if (entityHit instanceof SheepEntity) {
|
||||
final SheepEntity sh = (SheepEntity) entityHit;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Grid implements IGrid {
|
||||
|
||||
this.postEvent(new MENetworkPostCacheConstruction());
|
||||
|
||||
TickHandler.INSTANCE.addNetwork(this);
|
||||
TickHandler.instance().addNetwork(this);
|
||||
center.setGrid(this);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Grid implements IGrid {
|
||||
this.pivot = (GridNode) n.next();
|
||||
} else {
|
||||
this.pivot = null;
|
||||
TickHandler.INSTANCE.removeNetwork(this);
|
||||
TickHandler.instance().removeNetwork(this);
|
||||
this.myStorage.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ public class GridNode implements IGridNode, IPathItem {
|
||||
GridConnection.create(node, this, f.getOpposite());
|
||||
} catch (SecurityConnectionException e) {
|
||||
AELog.debug(e);
|
||||
TickHandler.INSTANCE.addCallable(node.getWorld(), new MachineSecurityBreak(this));
|
||||
TickHandler.instance().addCallable(node.getWorld(), new MachineSecurityBreak(this));
|
||||
|
||||
return;
|
||||
} catch (final FailedConnectionException e) {
|
||||
@@ -411,7 +411,7 @@ public class GridNode implements IGridNode, IPathItem {
|
||||
} catch (SecurityConnectionException e) {
|
||||
AELog.debug(e);
|
||||
|
||||
TickHandler.INSTANCE.addCallable(node.getWorld(), new MachineSecurityBreak(this));
|
||||
TickHandler.instance().addCallable(node.getWorld(), new MachineSecurityBreak(this));
|
||||
|
||||
return;
|
||||
} catch (final FailedConnectionException e) {
|
||||
|
||||
+16
-3
@@ -23,16 +23,18 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
@@ -72,10 +74,15 @@ public class EnergyGridCache implements IEnergyGrid {
|
||||
return Double.compare(percent1, percent2);
|
||||
};
|
||||
|
||||
private static final Comparator<IAEPowerStorage> COMPARATOR_HIGHEST_PRIORITY_FIRST = (o1, o2) -> Integer
|
||||
.compare(o2.getPriority(), o1.getPriority());
|
||||
private static final Comparator<IAEPowerStorage> COMPARATOR_LOWEST_PRIORITY_FIRST = (o1, o2) -> Integer
|
||||
.compare(o1.getPriority(), o2.getPriority());
|
||||
|
||||
private final NavigableSet<EnergyThreshold> interests = Sets.newTreeSet();
|
||||
private final double averageLength = 40.0;
|
||||
private final Set<IAEPowerStorage> providers = new LinkedHashSet<>();
|
||||
private final Set<IAEPowerStorage> requesters = new LinkedHashSet<>();
|
||||
private final SortedSet<IAEPowerStorage> providers = new ObjectRBTreeSet<>(COMPARATOR_HIGHEST_PRIORITY_FIRST);
|
||||
private final SortedSet<IAEPowerStorage> requesters = new ObjectRBTreeSet<>(COMPARATOR_LOWEST_PRIORITY_FIRST);
|
||||
private final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<>();
|
||||
@@ -572,6 +579,12 @@ public class EnergyGridCache implements IEnergyGrid {
|
||||
return this.stored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// MIN_VALUE to push it to the back
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
private void addCurrentAEPower(double amount) {
|
||||
this.stored += amount;
|
||||
|
||||
|
||||
+32
-20
@@ -82,21 +82,21 @@ public class SpatialPylonCache implements ISpatialCache {
|
||||
int pylonBlocks = 0;
|
||||
for (final SpatialPylonCluster cl : this.clusters.values()) {
|
||||
if (this.captureMax == null) {
|
||||
this.captureMax = cl.getMax().copy();
|
||||
this.captureMax = new DimensionalCoord(cl.getWorld(), cl.getBoundsMax());
|
||||
}
|
||||
if (this.captureMin == null) {
|
||||
this.captureMin = cl.getMin().copy();
|
||||
this.captureMin = new DimensionalCoord(cl.getWorld(), cl.getBoundsMin());
|
||||
}
|
||||
|
||||
pylonBlocks += cl.tileCount();
|
||||
|
||||
this.captureMin.x = Math.min(this.captureMin.x, cl.getMin().x);
|
||||
this.captureMin.y = Math.min(this.captureMin.y, cl.getMin().y);
|
||||
this.captureMin.z = Math.min(this.captureMin.z, cl.getMin().z);
|
||||
this.captureMin.x = Math.min(this.captureMin.x, cl.getBoundsMin().getX());
|
||||
this.captureMin.y = Math.min(this.captureMin.y, cl.getBoundsMin().getY());
|
||||
this.captureMin.z = Math.min(this.captureMin.z, cl.getBoundsMin().getZ());
|
||||
|
||||
this.captureMax.x = Math.max(this.captureMax.x, cl.getMax().x);
|
||||
this.captureMax.y = Math.max(this.captureMax.y, cl.getMax().y);
|
||||
this.captureMax.z = Math.max(this.captureMax.z, cl.getMax().z);
|
||||
this.captureMax.x = Math.max(this.captureMax.x, cl.getBoundsMax().getX());
|
||||
this.captureMax.y = Math.max(this.captureMax.y, cl.getBoundsMax().getY());
|
||||
this.captureMax.z = Math.max(this.captureMax.z, cl.getBoundsMax().getZ());
|
||||
}
|
||||
|
||||
double maxPower = 0;
|
||||
@@ -110,28 +110,40 @@ public class SpatialPylonCache implements ISpatialCache {
|
||||
case X:
|
||||
|
||||
this.isValid = this.isValid
|
||||
&& ((this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y)
|
||||
|| (this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z))
|
||||
&& ((this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y)
|
||||
|| (this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z));
|
||||
&& ((this.captureMax.y == cl.getBoundsMin().getY()
|
||||
|| this.captureMin.y == cl.getBoundsMax().getY())
|
||||
|| (this.captureMax.z == cl.getBoundsMin().getZ()
|
||||
|| this.captureMin.z == cl.getBoundsMax().getZ()))
|
||||
&& ((this.captureMax.y == cl.getBoundsMax().getY()
|
||||
|| this.captureMin.y == cl.getBoundsMin().getY())
|
||||
|| (this.captureMax.z == cl.getBoundsMax().getZ()
|
||||
|| this.captureMin.z == cl.getBoundsMin().getZ()));
|
||||
|
||||
break;
|
||||
case Y:
|
||||
|
||||
this.isValid = this.isValid
|
||||
&& ((this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x)
|
||||
|| (this.captureMax.z == cl.getMin().z || this.captureMin.z == cl.getMax().z))
|
||||
&& ((this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x)
|
||||
|| (this.captureMax.z == cl.getMax().z || this.captureMin.z == cl.getMin().z));
|
||||
&& ((this.captureMax.x == cl.getBoundsMin().getX()
|
||||
|| this.captureMin.x == cl.getBoundsMax().getX())
|
||||
|| (this.captureMax.z == cl.getBoundsMin().getZ()
|
||||
|| this.captureMin.z == cl.getBoundsMax().getZ()))
|
||||
&& ((this.captureMax.x == cl.getBoundsMax().getX()
|
||||
|| this.captureMin.x == cl.getBoundsMin().getX())
|
||||
|| (this.captureMax.z == cl.getBoundsMax().getZ()
|
||||
|| this.captureMin.z == cl.getBoundsMin().getZ()));
|
||||
|
||||
break;
|
||||
case Z:
|
||||
|
||||
this.isValid = this.isValid
|
||||
&& ((this.captureMax.y == cl.getMin().y || this.captureMin.y == cl.getMax().y)
|
||||
|| (this.captureMax.x == cl.getMin().x || this.captureMin.x == cl.getMax().x))
|
||||
&& ((this.captureMax.y == cl.getMax().y || this.captureMin.y == cl.getMin().y)
|
||||
|| (this.captureMax.x == cl.getMax().x || this.captureMin.x == cl.getMin().x));
|
||||
&& ((this.captureMax.y == cl.getBoundsMin().getY()
|
||||
|| this.captureMin.y == cl.getBoundsMax().getY())
|
||||
|| (this.captureMax.x == cl.getBoundsMin().getX()
|
||||
|| this.captureMin.x == cl.getBoundsMax().getX()))
|
||||
&& ((this.captureMax.y == cl.getBoundsMax().getY()
|
||||
|| this.captureMin.y == cl.getBoundsMin().getY())
|
||||
|| (this.captureMax.x == cl.getBoundsMax().getX()
|
||||
|| this.captureMin.x == cl.getBoundsMin().getX()));
|
||||
|
||||
break;
|
||||
case UNFORMED:
|
||||
|
||||
@@ -20,13 +20,32 @@ package appeng.me.cluster;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
|
||||
public interface IAECluster {
|
||||
|
||||
/**
|
||||
* The minimum x,y,z position still within the bounds of the cluster.
|
||||
*/
|
||||
BlockPos getBoundsMin();
|
||||
|
||||
/**
|
||||
* The maximum x,y,z position still within the bounds of the cluster.
|
||||
*/
|
||||
BlockPos getBoundsMax();
|
||||
|
||||
void updateStatus(boolean updateGrid);
|
||||
|
||||
void destroy();
|
||||
|
||||
/**
|
||||
* @return True if the cluster has been destroyed, but not yet removed from a
|
||||
* tile entity. Usually true during destruction.
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
Iterator<IGridHost> getTiles();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package appeng.me.cluster;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -29,16 +31,65 @@ import appeng.util.Platform;
|
||||
|
||||
public abstract class MBCalculator {
|
||||
|
||||
private static WeakReference<IAECluster> modificationInProgress = new WeakReference<>(null);
|
||||
|
||||
private final IAEMultiBlock target;
|
||||
|
||||
public MBCalculator(final IAEMultiBlock t) {
|
||||
this.target = t;
|
||||
}
|
||||
|
||||
public void calculateMultiblock(final World world, final WorldCoord loc) {
|
||||
if (Platform.isClient()) {
|
||||
public static void setModificationInProgress(IAECluster cluster) {
|
||||
IAECluster inProgress = modificationInProgress.get();
|
||||
if (inProgress == cluster) {
|
||||
return;
|
||||
}
|
||||
if (inProgress != null && cluster != null) {
|
||||
throw new IllegalStateException("A modification is already in-progress for: " + inProgress);
|
||||
}
|
||||
modificationInProgress = new WeakReference<>(cluster);
|
||||
}
|
||||
|
||||
public static boolean isModificationInProgress() {
|
||||
return modificationInProgress.get() != null;
|
||||
}
|
||||
|
||||
public void updateMultiblockAfterNeighborUpdate(final World world, final WorldCoord loc, BlockPos changedPos) {
|
||||
boolean recheck;
|
||||
|
||||
IAECluster 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
|
||||
recheck = true;
|
||||
} else {
|
||||
// If the location is outside, only re-check if it would now be considered part
|
||||
// of it
|
||||
recheck = isValidTileAt(world, changedPos.getX(), changedPos.getY(), changedPos.getZ());
|
||||
}
|
||||
} 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.
|
||||
recheck = true;
|
||||
}
|
||||
|
||||
if (recheck) {
|
||||
calculateMultiblock(world, loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void calculateMultiblock(final World world, final WorldCoord loc) {
|
||||
if (Platform.isClient() || isModificationInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAECluster currentCluster = target.getCluster();
|
||||
if (currentCluster != null && currentCluster.isDestroyed()) {
|
||||
return; // If we're still part of a cluster that is in the process of being destroyed,
|
||||
// don't recalc.
|
||||
}
|
||||
|
||||
try {
|
||||
final WorldCoord min = loc.copy();
|
||||
@@ -67,6 +118,7 @@ public abstract class MBCalculator {
|
||||
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)) {
|
||||
@@ -94,11 +146,21 @@ public abstract class MBCalculator {
|
||||
}
|
||||
} catch (final Throwable err) {
|
||||
AELog.debug(err);
|
||||
} finally {
|
||||
setModificationInProgress(null);
|
||||
}
|
||||
|
||||
this.disconnect();
|
||||
}
|
||||
|
||||
private static boolean isWithinBounds(BlockPos pos, BlockPos boundsMin, BlockPos boundsMax) {
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
return (x >= boundsMin.getX() && y >= boundsMin.getY() && z >= boundsMin.getZ() && x <= boundsMax.getX()
|
||||
&& y <= boundsMax.getY() && z <= boundsMax.getZ());
|
||||
}
|
||||
|
||||
private boolean isValidTileAt(final World w, final int x, final int y, final int z) {
|
||||
return this.isValidTile(w.getBlockEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -70,6 +71,7 @@ import appeng.crafting.CraftingWatcher;
|
||||
import appeng.crafting.MECraftingInventory;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.MBCalculator;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.tile.crafting.CraftingMonitorBlockEntity;
|
||||
import appeng.tile.crafting.CraftingBlockEntity;
|
||||
@@ -80,8 +82,8 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
|
||||
private static final String LOG_MARK_AS_COMPLETE = "Completed job for %s.";
|
||||
|
||||
private final WorldCoord min;
|
||||
private final WorldCoord max;
|
||||
private final BlockPos boundsMin;
|
||||
private final BlockPos boundsMax;
|
||||
private final int[] usedOps = new int[3];
|
||||
private final Map<ICraftingPatternDetails, TaskProgress> tasks = new HashMap<>();
|
||||
// INSTANCE sate
|
||||
@@ -112,11 +114,12 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
private long startItemCount;
|
||||
private long remainingItemCount;
|
||||
|
||||
public CraftingCPUCluster(final WorldCoord min, final WorldCoord max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
public CraftingCPUCluster(final WorldCoord boundsMin, final WorldCoord boundsMax) {
|
||||
this.boundsMin = boundsMin.getBlockPos();
|
||||
this.boundsMax = boundsMax.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return this.isDestroyed;
|
||||
}
|
||||
@@ -125,6 +128,16 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
return this.myLastLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBoundsMin() {
|
||||
return boundsMin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBoundsMax() {
|
||||
return boundsMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* add a new Listener to the monitor, be sure to properly remove yourself when
|
||||
* your done.
|
||||
@@ -160,19 +173,24 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
|
||||
}
|
||||
this.isDestroyed = true;
|
||||
|
||||
boolean posted = false;
|
||||
MBCalculator.setModificationInProgress(this);
|
||||
try {
|
||||
boolean posted = false;
|
||||
|
||||
for (final CraftingBlockEntity r : this.tiles) {
|
||||
final IGridNode n = r.getActionableNode();
|
||||
if (n != null && !posted) {
|
||||
final IGrid g = n.getGrid();
|
||||
if (g != null) {
|
||||
g.postEvent(new MENetworkCraftingCpuChange(n));
|
||||
posted = true;
|
||||
for (final CraftingBlockEntity r : this.tiles) {
|
||||
final IGridNode n = r.getActionableNode();
|
||||
if (n != null && !posted) {
|
||||
final IGrid g = n.getGrid();
|
||||
if (g != null) {
|
||||
g.postEvent(new MENetworkCraftingCpuChange(n));
|
||||
posted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.updateStatus(null);
|
||||
r.updateStatus(null);
|
||||
}
|
||||
} finally {
|
||||
MBCalculator.setModificationInProgress(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.me.cluster.implementations;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -36,13 +37,14 @@ import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.me.cache.helpers.ConnectionWrapper;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.MBCalculator;
|
||||
import appeng.tile.qnb.QuantumBridgeBlockEntity;
|
||||
import appeng.util.iterators.ChainedIterator;
|
||||
|
||||
public class QuantumCluster implements ILocatable, IAECluster {
|
||||
|
||||
private final WorldCoord min;
|
||||
private final WorldCoord max;
|
||||
private final BlockPos boundsMin;
|
||||
private final BlockPos boundsMax;
|
||||
private boolean isDestroyed = false;
|
||||
private boolean updateStatus = true;
|
||||
private QuantumBridgeBlockEntity[] Ring;
|
||||
@@ -53,8 +55,8 @@ public class QuantumCluster implements ILocatable, IAECluster {
|
||||
private QuantumBridgeBlockEntity center;
|
||||
|
||||
public QuantumCluster(final WorldCoord min, final WorldCoord max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.boundsMin = min.getBlockPos();
|
||||
this.boundsMax = max.getBlockPos();
|
||||
this.setRing(new QuantumBridgeBlockEntity[8]);
|
||||
}
|
||||
|
||||
@@ -185,6 +187,21 @@ public class QuantumCluster implements ILocatable, IAECluster {
|
||||
return this.thisSide != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBoundsMin() {
|
||||
return boundsMin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBoundsMax() {
|
||||
return boundsMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return isDestroyed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.isDestroyed) {
|
||||
@@ -192,25 +209,30 @@ public class QuantumCluster implements ILocatable, IAECluster {
|
||||
}
|
||||
this.isDestroyed = true;
|
||||
|
||||
if (this.registered) {
|
||||
// FIXME FABRIC -> onWorldUnload event
|
||||
MBCalculator.setModificationInProgress(this);
|
||||
try {
|
||||
if (this.registered) {
|
||||
// FIXME FABRIC -> onWorldUnload event
|
||||
// FIXME FABRIC MinecraftForge.EVENT_BUS.unregister(this);
|
||||
this.registered = false;
|
||||
}
|
||||
|
||||
if (this.thisSide != 0) {
|
||||
this.updateStatus(true);
|
||||
LocatableEventAnnounce.EVENT.invoker().onLocatableAnnounce(this, LocatableEvent.UNREGISTER);
|
||||
if (this.thisSide != 0) {
|
||||
this.updateStatus(true);
|
||||
LocatableEventAnnounce.EVENT.invoker().onLocatableAnnounce(this, LocatableEvent.UNREGISTER);
|
||||
}
|
||||
|
||||
this.center.updateStatus(null, (byte) -1, this.isUpdateStatus());
|
||||
|
||||
for (final QuantumBridgeBlockEntity r : this.getRing()) {
|
||||
r.updateStatus(null, (byte) -1, this.isUpdateStatus());
|
||||
}
|
||||
|
||||
this.center = null;
|
||||
this.setRing(new QuantumBridgeBlockEntity[8]);
|
||||
} finally {
|
||||
MBCalculator.setModificationInProgress(null);
|
||||
}
|
||||
|
||||
this.center.updateStatus(null, (byte) -1, this.isUpdateStatus());
|
||||
|
||||
for (final QuantumBridgeBlockEntity r : this.getRing()) {
|
||||
r.updateStatus(null, (byte) -1, this.isUpdateStatus());
|
||||
}
|
||||
|
||||
this.center = null;
|
||||
this.setRing(new QuantumBridgeBlockEntity[8]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
@@ -47,8 +46,7 @@ public class SpatialPylonCalculator extends MBCalculator {
|
||||
|
||||
@Override
|
||||
public IAECluster createCluster(final World w, final WorldCoord min, final WorldCoord max) {
|
||||
return new SpatialPylonCluster(new DimensionalCoord(w, min.x, min.y, min.z),
|
||||
new DimensionalCoord(w, max.x, max.y, max.z));
|
||||
return new SpatialPylonCluster(w, min.getBlockPos(), max.getBlockPos());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,30 +22,35 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.MBCalculator;
|
||||
import appeng.tile.spatial.SpatialPylonBlockEntity;
|
||||
|
||||
public class SpatialPylonCluster implements IAECluster {
|
||||
|
||||
private final DimensionalCoord min;
|
||||
private final DimensionalCoord max;
|
||||
private final World world;
|
||||
private final BlockPos boundsMin;
|
||||
private final BlockPos boundsMax;
|
||||
private final List<SpatialPylonBlockEntity> line = new ArrayList<>();
|
||||
private boolean isDestroyed = false;
|
||||
|
||||
private Axis currentAxis = Axis.UNFORMED;
|
||||
private boolean isValid;
|
||||
|
||||
public SpatialPylonCluster(final DimensionalCoord min, final DimensionalCoord max) {
|
||||
this.min = min.copy();
|
||||
this.max = max.copy();
|
||||
public SpatialPylonCluster(final World world, final BlockPos boundsMin, final BlockPos boundsMax) {
|
||||
this.world = world;
|
||||
this.boundsMin = boundsMin.toImmutable();
|
||||
this.boundsMax = boundsMax.toImmutable();
|
||||
|
||||
if (this.getMin().x != this.getMax().x) {
|
||||
if (this.getBoundsMin().getX() != this.getBoundsMax().getX()) {
|
||||
this.setCurrentAxis(Axis.X);
|
||||
} else if (this.getMin().y != this.getMax().y) {
|
||||
} else if (this.getBoundsMin().getY() != this.getBoundsMax().getY()) {
|
||||
this.setCurrentAxis(Axis.Y);
|
||||
} else if (this.getMin().z != this.getMax().z) {
|
||||
} else if (this.getBoundsMin().getZ() != this.getBoundsMax().getZ()) {
|
||||
this.setCurrentAxis(Axis.Z);
|
||||
} else {
|
||||
this.setCurrentAxis(Axis.UNFORMED);
|
||||
@@ -59,6 +64,11 @@ public class SpatialPylonCluster implements IAECluster {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return isDestroyed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
@@ -67,8 +77,13 @@ public class SpatialPylonCluster implements IAECluster {
|
||||
}
|
||||
this.isDestroyed = true;
|
||||
|
||||
for (final SpatialPylonBlockEntity r : this.getLine()) {
|
||||
r.updateStatus(null);
|
||||
MBCalculator.setModificationInProgress(this);
|
||||
try {
|
||||
for (final SpatialPylonBlockEntity r : this.getLine()) {
|
||||
r.updateStatus(null);
|
||||
}
|
||||
} finally {
|
||||
MBCalculator.setModificationInProgress(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +112,18 @@ public class SpatialPylonCluster implements IAECluster {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public DimensionalCoord getMax() {
|
||||
return this.max;
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public DimensionalCoord getMin() {
|
||||
return this.min;
|
||||
@Override
|
||||
public BlockPos getBoundsMax() {
|
||||
return this.boundsMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getBoundsMin() {
|
||||
return this.boundsMin;
|
||||
}
|
||||
|
||||
List<SpatialPylonBlockEntity> getLine() {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class AENetworkProxy implements IGridBlock {
|
||||
|
||||
public void validate() {
|
||||
if (this.gp instanceof AEBaseBlockEntity) {
|
||||
TickHandler.INSTANCE.addInit((AEBaseBlockEntity) this.gp);
|
||||
TickHandler.instance().addInit((AEBaseBlockEntity) this.gp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ public class AnnihilationPlanePart extends BasicStatePart implements IGridTickab
|
||||
performBreakBlock(w, pos, blockState, energy, requiredPower, items);
|
||||
} else {
|
||||
this.breaking = true;
|
||||
TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this);
|
||||
TickHandler.instance().addCallable(this.getTile().getWorld(), this);
|
||||
}
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
@@ -138,14 +138,14 @@ public class MEP2PTunnelPart extends P2PTunnelPart<MEP2PTunnelPart> implements I
|
||||
if (!this.getProxy().getPath().isNetworkBooting()) {
|
||||
if (!this.getProxy().getEnergy().isNetworkPowered()) {
|
||||
this.connection.markDestroy();
|
||||
TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection);
|
||||
TickHandler.instance().addCallable(this.getTile().getWorld(), this.connection);
|
||||
} else {
|
||||
if (this.getProxy().isActive()) {
|
||||
this.connection.markCreate();
|
||||
TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection);
|
||||
TickHandler.instance().addCallable(this.getTile().getWorld(), this.connection);
|
||||
} else {
|
||||
this.connection.markDestroy();
|
||||
TickHandler.INSTANCE.addCallable(this.getTile().getWorld(), this.connection);
|
||||
TickHandler.instance().addCallable(this.getTile().getWorld(), this.connection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ public class AEBaseBlockEntity extends BlockEntity implements IOrientable, IComm
|
||||
if (this.world != null) {
|
||||
this.world.markDirty(this.pos, this);
|
||||
if (!this.markDirtyQueued) {
|
||||
TickHandler.INSTANCE.addCallable(null, this::markDirtyAtEndOfTick);
|
||||
TickHandler.instance().addCallable(null, this::markDirtyAtEndOfTick);
|
||||
this.markDirtyQueued = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +118,11 @@ public class CraftingBlockEntity extends AENetworkBlockEntity implements IAEMult
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.getProxy().setVisualRepresentation(this.getItemFromTile(this));
|
||||
this.updateMultiBlock();
|
||||
this.calc.calculateMultiblock(world, getLocation());
|
||||
}
|
||||
|
||||
public void updateMultiBlock() {
|
||||
this.calc.calculateMultiblock(this.world, this.getLocation());
|
||||
public void updateMultiBlock(BlockPos changedPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), changedPos);
|
||||
}
|
||||
|
||||
public void updateStatus(final CraftingCPUCluster c) {
|
||||
|
||||
@@ -121,7 +121,7 @@ public class CableBusBlockEntity extends AEBaseBlockEntity implements AEMultiTil
|
||||
@Override
|
||||
public void cancelRemoval() {
|
||||
super.cancelRemoval();
|
||||
TickHandler.INSTANCE.addInit(this);
|
||||
TickHandler.instance().addInit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,4 +69,10 @@ public class CreativeEnergyCellBlockEntity extends AENetworkBlockEntity implemen
|
||||
public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) {
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// MAX_VALUE to move creative cells to the front.
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,16 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
public class DenseEnergyCellBlockEntity extends EnergyCellBlockEntity {
|
||||
|
||||
private final static double MAX_STORED = 200000 * 8;
|
||||
|
||||
public DenseEnergyCellBlockEntity(BlockEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
this.setInternalMaxPower(200000 * 8);
|
||||
this.setInternalMaxPower(MAX_STORED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 1600;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,10 @@ import appeng.util.SettingsFrom;
|
||||
|
||||
public class EnergyCellBlockEntity extends AENetworkBlockEntity implements IAEPowerStorage {
|
||||
|
||||
private static final double MAX_STORED = 200000.0;
|
||||
|
||||
private double internalCurrentPower = 0.0;
|
||||
private double internalMaxPower = 200000.0;
|
||||
private double internalMaxPower = MAX_STORED;
|
||||
|
||||
private byte currentMeta = -1;
|
||||
|
||||
@@ -180,6 +182,11 @@ public class EnergyCellBlockEntity extends AENetworkBlockEntity implements IAEPo
|
||||
return pm.divide(this.extractAEPower(pm.multiply(amt), mode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
private double extractAEPower(double amt, final Actionable mode) {
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
if (this.internalCurrentPower > amt) {
|
||||
@@ -219,4 +226,5 @@ public class EnergyCellBlockEntity extends AENetworkBlockEntity implements IAEPo
|
||||
void setInternalMaxPower(final double internalMaxPower) {
|
||||
this.internalMaxPower = internalMaxPower;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,18 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.networking.GridFlags;
|
||||
@@ -266,8 +278,8 @@ public class QuantumBridgeBlockEntity extends AENetworkInvBlockEntity implements
|
||||
return AECableType.DENSE_SMART;
|
||||
}
|
||||
|
||||
public void neighborUpdate() {
|
||||
this.calc.calculateMultiblock(this.world, this.getLocation());
|
||||
public void neighborUpdate(BlockPos fromPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), fromPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -102,7 +102,7 @@ public class SpatialIOPortBlockEntity extends AENetworkInvBlockEntity implements
|
||||
if (Platform.isServer()) {
|
||||
final ItemStack cell = this.inv.getInvStack(0);
|
||||
if (this.isSpatialCell(cell)) {
|
||||
TickHandler.INSTANCE.addCallable(null, this);// this needs to be cross world synced.
|
||||
TickHandler.instance().addCallable(null, this);// this needs to be cross world synced.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,15 @@ import java.util.EnumSet;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
@@ -77,7 +86,7 @@ public class SpatialPylonBlockEntity extends AENetworkBlockEntity implements IAE
|
||||
@Override
|
||||
public void onReady() {
|
||||
super.onReady();
|
||||
this.neighborUpdate();
|
||||
this.calc.calculateMultiblock(world, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,8 +95,8 @@ public class SpatialPylonBlockEntity extends AENetworkBlockEntity implements IAE
|
||||
super.markRemoved();
|
||||
}
|
||||
|
||||
public void neighborUpdate() {
|
||||
this.calc.calculateMultiblock(this.world, this.getLocation());
|
||||
public void neighborUpdate(BlockPos changedPos) {
|
||||
this.calc.updateMultiblockAfterNeighborUpdate(this.world, this.getLocation(), changedPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,9 +129,9 @@ public class SpatialPylonBlockEntity extends AENetworkBlockEntity implements IAE
|
||||
this.displayBits = 0;
|
||||
|
||||
if (this.cluster != null) {
|
||||
if (this.cluster.getMin().equals(this.getLocation())) {
|
||||
if (this.cluster.getBoundsMin().equals(this.getLocation())) {
|
||||
this.displayBits = DISPLAY_END_MIN;
|
||||
} else if (this.cluster.getMax().equals(this.getLocation())) {
|
||||
} else if (this.cluster.getBoundsMax().equals(this.getLocation())) {
|
||||
this.displayBits = DISPLAY_END_MAX;
|
||||
} else {
|
||||
this.displayBits = DISPLAY_MIDDLE;
|
||||
|
||||
@@ -1097,7 +1097,7 @@ public class Platform {
|
||||
|
||||
public static void notifyBlocksOfNeighbors(final World world, final BlockPos pos) {
|
||||
if (!world.isClient) {
|
||||
TickHandler.INSTANCE.addCallable(world, new BlockUpdate(pos));
|
||||
TickHandler.instance().addCallable(world, new BlockUpdate(pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user