mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-15 09:34:50 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52563aa5c2 | ||
|
|
76708883c0 | ||
|
|
0a1ee81780 |
No files matched your search
@@ -84,7 +84,17 @@ public abstract class AbstractConduit implements IConduit {
|
||||
|
||||
protected boolean connectionsDirty = true;
|
||||
|
||||
protected boolean needUpdateConnections = false;
|
||||
/**
|
||||
* This shows if the currently running connection update should not finish with settings connectionsDirty to false.
|
||||
* If this is true, it will trigger a reconnection on the next Tick.
|
||||
* <p>
|
||||
* Use the method needUpdateConnections() instead of setting this to true.
|
||||
*
|
||||
* @see needUpdateConnections()
|
||||
*/
|
||||
private boolean needUpdateConnections = false;
|
||||
|
||||
private boolean isUpdatingConnections = false;
|
||||
|
||||
protected AbstractConduit() {}
|
||||
|
||||
@@ -436,10 +446,13 @@ public abstract class AbstractConduit implements IConduit {
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
if (!connectionsDirty) {
|
||||
if (!connectionsDirty && !needUpdateConnections) {
|
||||
return;
|
||||
}
|
||||
|
||||
isUpdatingConnections = true;
|
||||
needUpdateConnections = false;
|
||||
|
||||
boolean externalConnectionsChanged = false;
|
||||
List<ForgeDirection> copy = new ArrayList<ForgeDirection>(externalConnections);
|
||||
// remove any no longer valid connections
|
||||
@@ -463,15 +476,22 @@ public abstract class AbstractConduit implements IConduit {
|
||||
connectionsChanged();
|
||||
}
|
||||
|
||||
if (needUpdateConnections) {
|
||||
needUpdateConnections = false;
|
||||
} else {
|
||||
connectionsDirty = false;
|
||||
}
|
||||
connectionsDirty = false;
|
||||
isUpdatingConnections = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method prevents connection update from getting completed successfully by not settings connectionsDirty to
|
||||
* false. This will trigger an connection update at the next Tick.
|
||||
* <p>
|
||||
* Only use this while executing updateConnections().
|
||||
* <p>
|
||||
* See this PR for more info: https://github.com/GTNewHorizons/EnderIO/pull/111
|
||||
*/
|
||||
protected void needUpdateConnections() {
|
||||
needUpdateConnections = true;
|
||||
if (isUpdatingConnections) {
|
||||
needUpdateConnections = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -175,6 +175,7 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
|
||||
node = part.getGridNode();
|
||||
}
|
||||
if (node == null) {
|
||||
// The GridNode has not been initialized yet, let's try on the next Tick.
|
||||
needUpdateConnections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,10 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
if (maxReceive < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int res = super.receiveEnergy(container, maxReceive, simulate);
|
||||
if (res != 0 && !simulate) {
|
||||
updateDamage(container);
|
||||
@@ -148,6 +152,10 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
}
|
||||
|
||||
public int extractEnergyInternal(ItemStack container, int maxExtract, boolean simulate) {
|
||||
if (maxExtract < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int res = super.extractEnergy(container, maxExtract, simulate);
|
||||
if (res != 0 && !simulate) {
|
||||
updateDamage(container);
|
||||
|
||||
@@ -67,6 +67,12 @@ public class ItemTeleportStaff extends ItemTravelStaff {
|
||||
return equipped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
// Don't allow receiving energy, since we have infinite energy.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
// Don't allow extracting energy.
|
||||
|
||||
@@ -103,6 +103,10 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
if (maxReceive < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int res = super.receiveEnergy(container, maxReceive, simulate);
|
||||
if (res != 0 && !simulate) {
|
||||
updateDamage(container);
|
||||
@@ -112,6 +116,10 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IItemOfTrave
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
if (maxExtract < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int res = super.extractEnergy(container, maxExtract, simulate);
|
||||
if (res != 0 && !simulate) {
|
||||
updateDamage(container);
|
||||
|
||||
Reference in new issue
Block a user