1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-03 15:13:07 +00:00

Various improvements to peripheral invalidation

- Abstract peripheral ID and type checking into separate class
 - Update peripherals directly rather than marking as invalid then
   fetching from the network.
 - Update peripherals when adjacent tiles change

This does result in a slightly more ugly interface, but reduces the
amount of work needed to perform partial updates of peripherals, such as
those done by neighbouring tile updates.
This commit is contained in:
SquidDev
2018-04-16 18:22:28 +01:00
parent 04f162ef25
commit 6cf32f1f74
8 changed files with 289 additions and 201 deletions

View File

@@ -23,7 +23,6 @@ import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
@@ -379,17 +378,10 @@ public class NetworkTest
remotePeripherals.putAll( change.peripheralsAdded() );
}
@Nonnull
@Override
public Map<String, IPeripheral> getPeripherals()
{
return Collections.unmodifiableMap( localPeripherals );
}
public NetworkElement addPeripheral( String name )
{
localPeripherals.put( name, new NetworkPeripheral() );
getNode().invalidate();
getNode().updatePeripherals( localPeripherals );
return this;
}