1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-30 05:12:58 +00:00

Move WiredNode default methods to the impl

This commit is contained in:
Jonathan Coates
2024-03-10 10:00:52 +00:00
parent d38b1da974
commit 451a2593ce
4 changed files with 27 additions and 24 deletions

View File

@@ -40,6 +40,26 @@ public final class WiredNodeImpl implements WiredNode {
network = new WiredNetworkImpl(this);
}
@Override
public boolean connectTo(WiredNode node) {
return network.connect(this, node);
}
@Override
public boolean disconnectFrom(WiredNode node) {
return network == ((WiredNodeImpl) node).network && network.disconnect(this, node);
}
@Override
public boolean remove() {
return network.remove(this);
}
@Override
public void updatePeripherals(Map<String, IPeripheral> peripherals) {
network.updatePeripherals(this, peripherals);
}
@Override
public synchronized void addReceiver(PacketReceiver receiver) {
if (receivers == null) receivers = new HashSet<>();

View File

@@ -15,7 +15,6 @@ import net.minecraft.nbt.Tag;
import net.minecraft.world.level.Level;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
import static dan200.computercraft.core.util.Nullability.assertNonNull;
@@ -86,11 +85,6 @@ public final class WiredModemLocalPeripheral {
return peripheral != null ? type + "_" + id : null;
}
@Nullable
public IPeripheral getPeripheral() {
return peripheral;
}
public boolean hasPeripheral() {
return peripheral != null;
}
@@ -100,9 +94,7 @@ public final class WiredModemLocalPeripheral {
}
public Map<String, IPeripheral> toMap() {
return peripheral == null
? Map.of()
: Collections.singletonMap(type + "_" + id, peripheral);
return peripheral == null ? Map.of() : Map.of(type + "_" + id, peripheral);
}
public void write(CompoundTag tag, String suffix) {