This commit is contained in:
parent
f2a3e61603
commit
38cad3b0f1
1 changed files with 12 additions and 9 deletions
|
@ -57,25 +57,24 @@ public class TRPowerNet {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void tick(PowerTickEvent evt) {
|
public synchronized void tick(PowerTickEvent evt) {
|
||||||
evt.getWorld().theProfiler.startSection("TechRebornPowerNet");
|
evt.getWorld().theProfiler.startSection("TechRebornPowerNet");
|
||||||
if (tick < 20) {
|
if (tick < 20) {
|
||||||
tick++;
|
tick++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tick % 80 == 0) {
|
if (tick % 80 == 0) {
|
||||||
List<CableMultipart> oldCables = new ArrayList<>();
|
for (Iterator<CableMultipart> it = cables.iterator(); it.hasNext(); ) {
|
||||||
for (CableMultipart cableMultipart : cables) {
|
CableMultipart cableMultipart = it.next();
|
||||||
if (cableMultipart.getWorld() == null || cableMultipart.getPos() == null) {
|
if (cableMultipart.getWorld() == null || cableMultipart.getPos() == null) {
|
||||||
oldCables.add(cableMultipart);
|
it.remove();
|
||||||
}
|
}
|
||||||
CableMultipart mp = cableMultipart.getPartFromWorld(cableMultipart.getWorld(), cableMultipart.getPos(),
|
CableMultipart mp = cableMultipart.getPartFromWorld(cableMultipart.getWorld(), cableMultipart.getPos(),
|
||||||
null);
|
null);
|
||||||
if (mp == null) {
|
if (mp == null) {
|
||||||
oldCables.add(cableMultipart);
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cables.removeAll(oldCables);
|
|
||||||
}
|
}
|
||||||
if (!cables.isEmpty()) {
|
if (!cables.isEmpty()) {
|
||||||
ArrayList<EnergyHandler> collectibles = new ArrayList();
|
ArrayList<EnergyHandler> collectibles = new ArrayList();
|
||||||
|
@ -106,13 +105,17 @@ public class TRPowerNet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addElement(CableMultipart te) {
|
public void addElement(CableMultipart te) {
|
||||||
if (!cables.contains(te)) {
|
synchronized (cables){
|
||||||
cables.add(te);
|
if (!cables.contains(te)) {
|
||||||
|
cables.add(te);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeElement(CableMultipart te) {
|
public void removeElement(CableMultipart te) {
|
||||||
cables.remove(te);
|
synchronized (cables){
|
||||||
|
cables.remove(te);
|
||||||
|
}
|
||||||
this.rebuild();
|
this.rebuild();
|
||||||
this.checkAndRemoveOldEndpoints();
|
this.checkAndRemoveOldEndpoints();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue