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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user