mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-12-10 07:58:05 +00:00
Initial pass of the API breaking changes for 1.19.3 (#1232)
- Remove deprecated API members in prep for 1.19.3. This allows us to remove the mc-stubs and forge-stubs projects. - Make several methods take a MinecraftServer instead of a Level (or nothing at all). - Remove I prefixes from a whole bunch of interfaces, making things a little more consistent with Java conventions. This avoids touching the "main" interfaces people consume for now. I want to do that another Minecraft version, to avoid making the update too painful. - Remove IFileSystem and associated getters. This has never worked very well and I don't think has got much (any?) usage.
This commit is contained in:
@@ -21,14 +21,12 @@ dependencies {
|
||||
clientImplementation(clientClasses(project(":common-api")))
|
||||
|
||||
compileOnly(libs.bundles.externalMods.common)
|
||||
compileOnly(project(":forge-stubs"))
|
||||
|
||||
compileOnly(libs.mixin)
|
||||
annotationProcessorEverywhere(libs.autoService)
|
||||
|
||||
testImplementation(testFixtures(project(":core")))
|
||||
testImplementation(libs.bundles.test)
|
||||
testImplementation(project(":forge-stubs"))
|
||||
testRuntimeOnly(libs.bundles.testRuntime)
|
||||
|
||||
testModImplementation(testFixtures(project(":core")))
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeDataProvider;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeDataProvider;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.core.metrics.Metric;
|
||||
import dan200.computercraft.core.metrics.Metrics;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
@@ -272,8 +272,8 @@ public final class LanguageProvider implements DataProvider {
|
||||
Registries.ITEMS.stream()
|
||||
.filter(x -> Registries.ITEMS.getKey(x).getNamespace().equals(ComputerCraftAPI.MOD_ID))
|
||||
.map(Item::getDescriptionId),
|
||||
turtleUpgrades.getGeneratedUpgrades().stream().map(IUpgradeBase::getUnlocalisedAdjective),
|
||||
pocketUpgrades.getGeneratedUpgrades().stream().map(IUpgradeBase::getUnlocalisedAdjective),
|
||||
turtleUpgrades.getGeneratedUpgrades().stream().map(UpgradeBase::getUnlocalisedAdjective),
|
||||
pocketUpgrades.getGeneratedUpgrades().stream().map(UpgradeBase::getUnlocalisedAdjective),
|
||||
Metric.metrics().values().stream().map(x -> AggregatedMetric.TRANSLATION_PREFIX + x.name() + ".name"),
|
||||
getConfigKeys(ConfigSpec.serverSpec),
|
||||
getConfigKeys(ConfigSpec.clientSpec)
|
||||
|
||||
@@ -7,21 +7,20 @@ package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.detail.BlockReference;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.detail.IDetailProvider;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.filesystem.WritableMount;
|
||||
import dan200.computercraft.api.lua.GenericSource;
|
||||
import dan200.computercraft.api.lua.ILuaAPIFactory;
|
||||
import dan200.computercraft.api.media.IMediaProvider;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.api.media.MediaProvider;
|
||||
import dan200.computercraft.api.network.PacketNetwork;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.redstone.BundledRedstoneProvider;
|
||||
import dan200.computercraft.api.turtle.TurtleRefuelHandler;
|
||||
import dan200.computercraft.core.apis.ApiFactories;
|
||||
import dan200.computercraft.core.asm.GenericMethod;
|
||||
import dan200.computercraft.core.filesystem.FileMount;
|
||||
import dan200.computercraft.impl.detail.DetailRegistryImpl;
|
||||
import dan200.computercraft.impl.network.wired.WiredNode;
|
||||
import dan200.computercraft.impl.network.wired.WiredNodeImpl;
|
||||
import dan200.computercraft.shared.computer.core.ServerContext;
|
||||
import dan200.computercraft.shared.details.BlockDetails;
|
||||
import dan200.computercraft.shared.details.ItemDetails;
|
||||
@@ -54,19 +53,15 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int createUniqueNumberedSaveDir(Level world, String parentSubPath) {
|
||||
var server = world.getServer();
|
||||
if (server == null) throw new IllegalArgumentException("Cannot find server from provided level");
|
||||
public final int createUniqueNumberedSaveDir(MinecraftServer server, String parentSubPath) {
|
||||
return ServerContext.get(server).getNextId(parentSubPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @Nullable IWritableMount createSaveDirMount(Level world, String subPath, long capacity) {
|
||||
var server = world.getServer();
|
||||
if (server == null) throw new IllegalArgumentException("Cannot find server from provided level");
|
||||
|
||||
public final @Nullable WritableMount createSaveDirMount(MinecraftServer server, String subPath, long capacity) {
|
||||
var root = ServerContext.get(server).storageDir().toFile();
|
||||
try {
|
||||
return new FileMount(new File(ServerContext.get(server).storageDir().toFile(), subPath), capacity);
|
||||
return new FileMount(new File(root, subPath), capacity);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
@@ -78,7 +73,7 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) {
|
||||
public final void registerBundledRedstoneProvider(BundledRedstoneProvider provider) {
|
||||
BundledRedstone.register(provider);
|
||||
}
|
||||
|
||||
@@ -88,12 +83,12 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void registerMediaProvider(IMediaProvider provider) {
|
||||
public final void registerMediaProvider(MediaProvider provider) {
|
||||
MediaProviders.register(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPacketNetwork getWirelessNetwork() {
|
||||
public final PacketNetwork getWirelessNetwork(MinecraftServer server) {
|
||||
return WirelessNetwork.getUniversal();
|
||||
}
|
||||
|
||||
@@ -102,13 +97,11 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
|
||||
ApiFactories.register(factory);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final IWiredNode createWiredNodeForElement(IWiredElement element) {
|
||||
return new WiredNode(element);
|
||||
public final WiredNode createWiredNodeForElement(WiredElement element) {
|
||||
return new WiredNodeImpl(element);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerRefuelHandler(TurtleRefuelHandler handler) {
|
||||
TurtleRefuelHandlers.register(handler);
|
||||
@@ -123,17 +116,4 @@ public abstract class AbstractComputerCraftAPI implements ComputerCraftAPIServic
|
||||
public final DetailRegistry<BlockReference> getBlockInWorldDetailRegistry() {
|
||||
return blockDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void registerDetailProvider(Class<T> type, IDetailProvider<T> provider) {
|
||||
if (type == ItemStack.class) {
|
||||
itemStackDetails.addProvider((IDetailProvider<ItemStack>) provider);
|
||||
} else if (type == BlockReference.class) {
|
||||
blockDetails.addProvider((IDetailProvider<BlockReference>) provider);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown detail provider " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.api.redstone.BundledRedstoneProvider;
|
||||
import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -19,12 +19,12 @@ import java.util.Objects;
|
||||
public final class BundledRedstone {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BundledRedstone.class);
|
||||
|
||||
private static final ArrayList<IBundledRedstoneProvider> providers = new ArrayList<>();
|
||||
private static final ArrayList<BundledRedstoneProvider> providers = new ArrayList<>();
|
||||
|
||||
private BundledRedstone() {
|
||||
}
|
||||
|
||||
public static synchronized void register(IBundledRedstoneProvider provider) {
|
||||
public static synchronized void register(BundledRedstoneProvider provider) {
|
||||
Objects.requireNonNull(provider, "provider cannot be null");
|
||||
if (!providers.contains(provider)) providers.add(provider);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.impl;
|
||||
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.media.IMediaProvider;
|
||||
import dan200.computercraft.api.media.MediaProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -19,12 +19,12 @@ import java.util.Set;
|
||||
public final class MediaProviders {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MediaProviders.class);
|
||||
|
||||
private static final Set<IMediaProvider> providers = new LinkedHashSet<>();
|
||||
private static final Set<MediaProvider> providers = new LinkedHashSet<>();
|
||||
|
||||
private MediaProviders() {
|
||||
}
|
||||
|
||||
public static synchronized void register(IMediaProvider provider) {
|
||||
public static synchronized void register(MediaProvider provider) {
|
||||
Objects.requireNonNull(provider, "provider cannot be null");
|
||||
providers.add(provider);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.impl;
|
||||
|
||||
import com.google.gson.*;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeSerialiser;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -36,11 +36,11 @@ import java.util.stream.Collectors;
|
||||
* @see TurtleUpgrades
|
||||
* @see PocketUpgrades
|
||||
*/
|
||||
public class UpgradeManager<R extends UpgradeSerialiser<? extends T>, T extends IUpgradeBase> extends SimpleJsonResourceReloadListener {
|
||||
public class UpgradeManager<R extends UpgradeSerialiser<? extends T>, T extends UpgradeBase> extends SimpleJsonResourceReloadListener {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public record UpgradeWrapper<R extends UpgradeSerialiser<? extends T>, T extends IUpgradeBase>(
|
||||
public record UpgradeWrapper<R extends UpgradeSerialiser<? extends T>, T extends UpgradeBase>(
|
||||
String id, T upgrade, R serialiser, String modId
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.impl.detail;
|
||||
|
||||
import dan200.computercraft.api.detail.DetailProvider;
|
||||
import dan200.computercraft.api.detail.DetailRegistry;
|
||||
import dan200.computercraft.api.detail.IDetailProvider;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -16,16 +16,16 @@ import java.util.*;
|
||||
* @param <T> The type of object that this registry provides details for.
|
||||
*/
|
||||
public class DetailRegistryImpl<T> implements DetailRegistry<T> {
|
||||
private final Collection<IDetailProvider<T>> providers = new ArrayList<>();
|
||||
private final IDetailProvider<T> basic;
|
||||
private final Collection<DetailProvider<T>> providers = new ArrayList<>();
|
||||
private final DetailProvider<T> basic;
|
||||
|
||||
public DetailRegistryImpl(IDetailProvider<T> basic) {
|
||||
public DetailRegistryImpl(DetailProvider<T> basic) {
|
||||
this.basic = basic;
|
||||
providers.add(basic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addProvider(IDetailProvider<T> provider) {
|
||||
public synchronized void addProvider(DetailProvider<T> provider) {
|
||||
Objects.requireNonNull(provider, "provider cannot be null");
|
||||
if (!providers.contains(provider)) providers.add(provider);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class InvariantChecker {
|
||||
private InvariantChecker() {
|
||||
}
|
||||
|
||||
public static void checkNode(WiredNode node) {
|
||||
public static void checkNode(WiredNodeImpl node) {
|
||||
if (!ENABLED) return;
|
||||
|
||||
var network = node.network;
|
||||
@@ -41,7 +41,7 @@ public final class InvariantChecker {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkNetwork(WiredNetwork network) {
|
||||
public static void checkNetwork(WiredNetworkImpl network) {
|
||||
if (!ENABLED) return;
|
||||
|
||||
for (var node : network.nodes) checkNode(node);
|
||||
|
||||
@@ -5,44 +5,44 @@
|
||||
*/
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.wired.IWiredNetworkChange;
|
||||
import dan200.computercraft.api.network.wired.WiredNetworkChange;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class WiredNetworkChange implements IWiredNetworkChange {
|
||||
private static final WiredNetworkChange EMPTY = new WiredNetworkChange(Collections.emptyMap(), Collections.emptyMap());
|
||||
final class WiredNetworkChangeImpl implements WiredNetworkChange {
|
||||
private static final WiredNetworkChangeImpl EMPTY = new WiredNetworkChangeImpl(Collections.emptyMap(), Collections.emptyMap());
|
||||
|
||||
private final Map<String, IPeripheral> removed;
|
||||
private final Map<String, IPeripheral> added;
|
||||
|
||||
private WiredNetworkChange(Map<String, IPeripheral> removed, Map<String, IPeripheral> added) {
|
||||
private WiredNetworkChangeImpl(Map<String, IPeripheral> removed, Map<String, IPeripheral> added) {
|
||||
this.removed = removed;
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
public static WiredNetworkChange changed(Map<String, IPeripheral> removed, Map<String, IPeripheral> added) {
|
||||
return new WiredNetworkChange(Collections.unmodifiableMap(removed), Collections.unmodifiableMap(added));
|
||||
static WiredNetworkChangeImpl changed(Map<String, IPeripheral> removed, Map<String, IPeripheral> added) {
|
||||
return new WiredNetworkChangeImpl(Collections.unmodifiableMap(removed), Collections.unmodifiableMap(added));
|
||||
}
|
||||
|
||||
public static WiredNetworkChange added(Map<String, IPeripheral> added) {
|
||||
return added.isEmpty() ? EMPTY : new WiredNetworkChange(Collections.emptyMap(), Collections.unmodifiableMap(added));
|
||||
static WiredNetworkChangeImpl added(Map<String, IPeripheral> added) {
|
||||
return added.isEmpty() ? EMPTY : new WiredNetworkChangeImpl(Collections.emptyMap(), Collections.unmodifiableMap(added));
|
||||
}
|
||||
|
||||
public static WiredNetworkChange removed(Map<String, IPeripheral> removed) {
|
||||
return removed.isEmpty() ? EMPTY : new WiredNetworkChange(Collections.unmodifiableMap(removed), Collections.emptyMap());
|
||||
static WiredNetworkChangeImpl removed(Map<String, IPeripheral> removed) {
|
||||
return removed.isEmpty() ? EMPTY : new WiredNetworkChangeImpl(Collections.unmodifiableMap(removed), Collections.emptyMap());
|
||||
}
|
||||
|
||||
public static WiredNetworkChange changeOf(Map<String, IPeripheral> oldPeripherals, Map<String, IPeripheral> newPeripherals) {
|
||||
static WiredNetworkChangeImpl changeOf(Map<String, IPeripheral> oldPeripherals, Map<String, IPeripheral> newPeripherals) {
|
||||
// Handle the trivial cases, where all peripherals have been added or removed.
|
||||
if (oldPeripherals.isEmpty() && newPeripherals.isEmpty()) {
|
||||
return EMPTY;
|
||||
} else if (oldPeripherals.isEmpty()) {
|
||||
return new WiredNetworkChange(Collections.emptyMap(), newPeripherals);
|
||||
return new WiredNetworkChangeImpl(Collections.emptyMap(), newPeripherals);
|
||||
} else if (newPeripherals.isEmpty()) {
|
||||
return new WiredNetworkChange(oldPeripherals, Collections.emptyMap());
|
||||
return new WiredNetworkChangeImpl(oldPeripherals, Collections.emptyMap());
|
||||
}
|
||||
|
||||
Map<String, IPeripheral> added = new HashMap<>(newPeripherals);
|
||||
@@ -80,13 +80,13 @@ public final class WiredNetworkChange implements IWiredNetworkChange {
|
||||
return added.isEmpty() && removed.isEmpty();
|
||||
}
|
||||
|
||||
void broadcast(Iterable<WiredNode> nodes) {
|
||||
void broadcast(Iterable<WiredNodeImpl> nodes) {
|
||||
if (!isEmpty()) {
|
||||
for (var node : nodes) node.element.networkChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void broadcast(WiredNode node) {
|
||||
void broadcast(WiredNodeImpl node) {
|
||||
if (!isEmpty()) {
|
||||
node.element.networkChanged(this);
|
||||
}
|
||||
@@ -7,30 +7,30 @@ package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public final class WiredNetwork implements IWiredNetwork {
|
||||
final class WiredNetworkImpl implements WiredNetwork {
|
||||
final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
Set<WiredNode> nodes;
|
||||
Set<WiredNodeImpl> nodes;
|
||||
private Map<String, IPeripheral> peripherals = new HashMap<>();
|
||||
|
||||
WiredNetwork(WiredNode node) {
|
||||
WiredNetworkImpl(WiredNodeImpl node) {
|
||||
nodes = new HashSet<>(1);
|
||||
nodes.add(node);
|
||||
}
|
||||
|
||||
private WiredNetwork(HashSet<WiredNode> nodes) {
|
||||
private WiredNetworkImpl(HashSet<WiredNodeImpl> nodes) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean connect(IWiredNode nodeU, IWiredNode nodeV) {
|
||||
public boolean connect(WiredNode nodeU, WiredNode nodeV) {
|
||||
var wiredU = checkNode(nodeU);
|
||||
var wiredV = checkNode(nodeV);
|
||||
if (nodeU == nodeV) throw new IllegalArgumentException("Cannot add a connection to oneself.");
|
||||
@@ -65,11 +65,11 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
peripherals.putAll(otherPeripherals);
|
||||
|
||||
if (!thisPeripherals.isEmpty()) {
|
||||
WiredNetworkChange.added(thisPeripherals).broadcast(otherNodes);
|
||||
WiredNetworkChangeImpl.added(thisPeripherals).broadcast(otherNodes);
|
||||
}
|
||||
|
||||
if (!otherPeripherals.isEmpty()) {
|
||||
WiredNetworkChange.added(otherPeripherals).broadcast(thisNodes);
|
||||
WiredNetworkChangeImpl.added(otherPeripherals).broadcast(thisNodes);
|
||||
}
|
||||
} finally {
|
||||
other.lock.writeLock().unlock();
|
||||
@@ -90,7 +90,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disconnect(IWiredNode nodeU, IWiredNode nodeV) {
|
||||
public boolean disconnect(WiredNode nodeU, WiredNode nodeV) {
|
||||
var wiredU = checkNode(nodeU);
|
||||
var wiredV = checkNode(nodeV);
|
||||
if (nodeU == nodeV) throw new IllegalArgumentException("Cannot remove a connection to oneself.");
|
||||
@@ -108,8 +108,8 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
// Determine if there is still some connection from u to v.
|
||||
// Note this is an inlining of reachableNodes which short-circuits
|
||||
// if all nodes are reachable.
|
||||
Queue<WiredNode> enqueued = new ArrayDeque<>();
|
||||
var reachableU = new HashSet<WiredNode>();
|
||||
Queue<WiredNodeImpl> enqueued = new ArrayDeque<>();
|
||||
var reachableU = new HashSet<WiredNodeImpl>();
|
||||
|
||||
reachableU.add(wiredU);
|
||||
enqueued.add(wiredU);
|
||||
@@ -127,7 +127,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
|
||||
// Create a new network with all U-reachable nodes/edges and remove them
|
||||
// from the existing graph.
|
||||
var networkU = new WiredNetwork(reachableU);
|
||||
var networkU = new WiredNetworkImpl(reachableU);
|
||||
networkU.lock.writeLock().lock();
|
||||
try {
|
||||
// Remove nodes from this network
|
||||
@@ -141,9 +141,9 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
|
||||
// Broadcast changes
|
||||
if (!peripherals.isEmpty()) WiredNetworkChange.removed(peripherals).broadcast(networkU.nodes);
|
||||
if (!peripherals.isEmpty()) WiredNetworkChangeImpl.removed(peripherals).broadcast(networkU.nodes);
|
||||
if (!networkU.peripherals.isEmpty()) {
|
||||
WiredNetworkChange.removed(networkU.peripherals).broadcast(nodes);
|
||||
WiredNetworkChangeImpl.removed(networkU.peripherals).broadcast(nodes);
|
||||
}
|
||||
|
||||
InvariantChecker.checkNetwork(this);
|
||||
@@ -161,7 +161,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(IWiredNode node) {
|
||||
public boolean remove(WiredNode node) {
|
||||
var wired = checkNode(node);
|
||||
|
||||
lock.writeLock().lock();
|
||||
@@ -177,7 +177,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
nodes.remove(wired);
|
||||
for (var neighbour : neighbours) neighbour.neighbours.remove(wired);
|
||||
|
||||
var wiredNetwork = new WiredNetwork(wired);
|
||||
var wiredNetwork = new WiredNetworkImpl(wired);
|
||||
|
||||
// If we're a leaf node in the graph (only one neighbour) then we don't need to
|
||||
// check for network splitting
|
||||
@@ -203,14 +203,14 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
// A split may cause 2..neighbours.size() separate networks, so we
|
||||
// iterate through our neighbour list, generating child networks.
|
||||
neighbours.removeAll(reachable);
|
||||
var maximals = new ArrayList<WiredNetwork>(neighbours.size() + 1);
|
||||
var maximals = new ArrayList<WiredNetworkImpl>(neighbours.size() + 1);
|
||||
maximals.add(wiredNetwork);
|
||||
maximals.add(new WiredNetwork(reachable));
|
||||
maximals.add(new WiredNetworkImpl(reachable));
|
||||
|
||||
while (!neighbours.isEmpty()) {
|
||||
reachable = reachableNodes(neighbours.iterator().next());
|
||||
neighbours.removeAll(reachable);
|
||||
maximals.add(new WiredNetwork(reachable));
|
||||
maximals.add(new WiredNetworkImpl(reachable));
|
||||
}
|
||||
|
||||
for (var network : maximals) network.lock.writeLock().lock();
|
||||
@@ -233,7 +233,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
|
||||
// Then broadcast network changes once all nodes are finalised
|
||||
for (var network : maximals) {
|
||||
WiredNetworkChange.changeOf(peripherals, network.peripherals).broadcast(network.nodes);
|
||||
WiredNetworkChangeImpl.changeOf(peripherals, network.peripherals).broadcast(network.nodes);
|
||||
}
|
||||
} finally {
|
||||
for (var network : maximals) network.lock.writeLock().unlock();
|
||||
@@ -249,7 +249,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePeripherals(IWiredNode node, Map<String, IPeripheral> newPeripherals) {
|
||||
public void updatePeripherals(WiredNode node, Map<String, IPeripheral> newPeripherals) {
|
||||
var wired = checkNode(node);
|
||||
Objects.requireNonNull(peripherals, "peripherals cannot be null");
|
||||
|
||||
@@ -258,7 +258,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
if (wired.network != this) throw new IllegalStateException("Node is not on this network");
|
||||
|
||||
var oldPeripherals = wired.peripherals;
|
||||
var change = WiredNetworkChange.changeOf(oldPeripherals, newPeripherals);
|
||||
var change = WiredNetworkChangeImpl.changeOf(oldPeripherals, newPeripherals);
|
||||
if (change.isEmpty()) return;
|
||||
|
||||
wired.peripherals = ImmutableMap.copyOf(newPeripherals);
|
||||
@@ -275,8 +275,8 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
}
|
||||
|
||||
static void transmitPacket(WiredNode start, Packet packet, double range, boolean interdimensional) {
|
||||
Map<WiredNode, TransmitPoint> points = new HashMap<>();
|
||||
static void transmitPacket(WiredNodeImpl start, Packet packet, double range, boolean interdimensional) {
|
||||
Map<WiredNodeImpl, TransmitPoint> points = new HashMap<>();
|
||||
var transmitTo = new TreeSet<TransmitPoint>();
|
||||
|
||||
{
|
||||
@@ -324,7 +324,7 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSingleNode(WiredNode wired, WiredNetwork wiredNetwork) {
|
||||
private void removeSingleNode(WiredNodeImpl wired, WiredNetworkImpl wiredNetwork) {
|
||||
wiredNetwork.lock.writeLock().lock();
|
||||
try {
|
||||
// Cache all the old nodes.
|
||||
@@ -337,11 +337,11 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
wired.peripherals = Collections.emptyMap();
|
||||
|
||||
// Broadcast the change
|
||||
if (!peripherals.isEmpty()) WiredNetworkChange.removed(peripherals).broadcast(wired);
|
||||
if (!peripherals.isEmpty()) WiredNetworkChangeImpl.removed(peripherals).broadcast(wired);
|
||||
|
||||
// Now remove all peripherals from this network and broadcast the change.
|
||||
peripherals.keySet().removeAll(wiredPeripherals.keySet());
|
||||
if (!wiredPeripherals.isEmpty()) WiredNetworkChange.removed(wiredPeripherals).broadcast(nodes);
|
||||
if (!wiredPeripherals.isEmpty()) WiredNetworkChangeImpl.removed(wiredPeripherals).broadcast(nodes);
|
||||
|
||||
} finally {
|
||||
wiredNetwork.lock.writeLock().unlock();
|
||||
@@ -349,11 +349,11 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
|
||||
private static class TransmitPoint implements Comparable<TransmitPoint> {
|
||||
final WiredNode node;
|
||||
final WiredNodeImpl node;
|
||||
double distance;
|
||||
boolean interdimensional;
|
||||
|
||||
TransmitPoint(WiredNode node, double distance, boolean interdimensional) {
|
||||
TransmitPoint(WiredNodeImpl node, double distance, boolean interdimensional) {
|
||||
this.node = node;
|
||||
this.distance = distance;
|
||||
this.interdimensional = interdimensional;
|
||||
@@ -368,22 +368,22 @@ public final class WiredNetwork implements IWiredNetwork {
|
||||
}
|
||||
}
|
||||
|
||||
private static WiredNode checkNode(IWiredNode node) {
|
||||
if (node instanceof WiredNode) {
|
||||
return (WiredNode) node;
|
||||
private static WiredNodeImpl checkNode(WiredNode node) {
|
||||
if (node instanceof WiredNodeImpl) {
|
||||
return (WiredNodeImpl) node;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown implementation of IWiredNode: " + node);
|
||||
}
|
||||
}
|
||||
|
||||
private static HashSet<WiredNode> reachableNodes(WiredNode start) {
|
||||
Queue<WiredNode> enqueued = new ArrayDeque<>();
|
||||
var reachable = new HashSet<WiredNode>();
|
||||
private static HashSet<WiredNodeImpl> reachableNodes(WiredNodeImpl start) {
|
||||
Queue<WiredNodeImpl> enqueued = new ArrayDeque<>();
|
||||
var reachable = new HashSet<WiredNodeImpl>();
|
||||
|
||||
reachable.add(start);
|
||||
enqueued.add(start);
|
||||
|
||||
WiredNode node;
|
||||
WiredNodeImpl node;
|
||||
while ((node = enqueued.poll()) != null) {
|
||||
for (var neighbour : node.neighbours) {
|
||||
// Otherwise attempt to enqueue this neighbour as well.
|
||||
@@ -5,39 +5,39 @@
|
||||
*/
|
||||
package dan200.computercraft.impl.network.wired;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketReceiver;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.IWiredSender;
|
||||
import dan200.computercraft.api.network.PacketReceiver;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredSender;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public final class WiredNode implements IWiredNode {
|
||||
private @Nullable Set<IPacketReceiver> receivers;
|
||||
public final class WiredNodeImpl implements WiredNode {
|
||||
private @Nullable Set<PacketReceiver> receivers;
|
||||
|
||||
final IWiredElement element;
|
||||
final WiredElement element;
|
||||
Map<String, IPeripheral> peripherals = Collections.emptyMap();
|
||||
|
||||
final HashSet<WiredNode> neighbours = new HashSet<>();
|
||||
volatile WiredNetwork network;
|
||||
final HashSet<WiredNodeImpl> neighbours = new HashSet<>();
|
||||
volatile WiredNetworkImpl network;
|
||||
|
||||
public WiredNode(IWiredElement element) {
|
||||
public WiredNodeImpl(WiredElement element) {
|
||||
this.element = element;
|
||||
network = new WiredNetwork(this);
|
||||
network = new WiredNetworkImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addReceiver(IPacketReceiver receiver) {
|
||||
public synchronized void addReceiver(PacketReceiver receiver) {
|
||||
if (receivers == null) receivers = new HashSet<>();
|
||||
receivers.add(receiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeReceiver(IPacketReceiver receiver) {
|
||||
public synchronized void removeReceiver(PacketReceiver receiver) {
|
||||
if (receivers != null) receivers.remove(receiver);
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ public final class WiredNode implements IWiredNode {
|
||||
@Override
|
||||
public void transmitSameDimension(Packet packet, double range) {
|
||||
Objects.requireNonNull(packet, "packet cannot be null");
|
||||
if (!(packet.sender() instanceof IWiredSender) || ((IWiredSender) packet.sender()).getNode() != this) {
|
||||
if (!(packet.sender() instanceof WiredSender) || ((WiredSender) packet.sender()).getNode() != this) {
|
||||
throw new IllegalArgumentException("Sender is not in the network");
|
||||
}
|
||||
|
||||
acquireReadLock();
|
||||
try {
|
||||
WiredNetwork.transmitPacket(this, packet, range, false);
|
||||
WiredNetworkImpl.transmitPacket(this, packet, range, false);
|
||||
} finally {
|
||||
network.lock.readLock().unlock();
|
||||
}
|
||||
@@ -81,25 +81,25 @@ public final class WiredNode implements IWiredNode {
|
||||
@Override
|
||||
public void transmitInterdimensional(Packet packet) {
|
||||
Objects.requireNonNull(packet, "packet cannot be null");
|
||||
if (!(packet.sender() instanceof IWiredSender) || ((IWiredSender) packet.sender()).getNode() != this) {
|
||||
if (!(packet.sender() instanceof WiredSender) || ((WiredSender) packet.sender()).getNode() != this) {
|
||||
throw new IllegalArgumentException("Sender is not in the network");
|
||||
}
|
||||
|
||||
acquireReadLock();
|
||||
try {
|
||||
WiredNetwork.transmitPacket(this, packet, 0, true);
|
||||
WiredNetworkImpl.transmitPacket(this, packet, 0, true);
|
||||
} finally {
|
||||
network.lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWiredElement getElement() {
|
||||
public WiredElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWiredNetwork getNetwork() {
|
||||
public WiredNetwork getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.detail.IDetailProvider;
|
||||
import dan200.computercraft.api.detail.DetailProvider;
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
|
||||
@@ -98,7 +98,7 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Registers ComputerCraft's registry entries and additional objects, such as {@link CauldronInteraction}s and
|
||||
* {@link IDetailProvider}s
|
||||
* {@link DetailProvider}s
|
||||
* <p>
|
||||
* The functions in this class should be called from a loader-specific class.
|
||||
*/
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
|
||||
import dan200.computercraft.api.redstone.BundledRedstoneProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
|
||||
public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider {
|
||||
public class DefaultBundledRedstoneProvider implements BundledRedstoneProvider {
|
||||
@Override
|
||||
public int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side) {
|
||||
return getDefaultBundledRedstoneOutput(world, pos, side);
|
||||
|
||||
@@ -314,7 +314,7 @@ public abstract class AbstractComputerBlockEntity extends BlockEntity implements
|
||||
var computer = ServerContext.get(server).registry().get(instanceID);
|
||||
if (computer == null) {
|
||||
if (computerID < 0) {
|
||||
computerID = ComputerCraftAPI.createUniqueNumberedSaveDir(level, IDAssigner.COMPUTER);
|
||||
computerID = ComputerCraftAPI.createUniqueNumberedSaveDir(server, IDAssigner.COMPUTER);
|
||||
BlockEntityHelpers.updateBlock(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.computer.core;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.core.apis.handles.ArrayByteChannel;
|
||||
import dan200.computercraft.core.filesystem.FileSystem;
|
||||
import dan200.computercraft.core.util.IoUtil;
|
||||
@@ -29,7 +29,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ResourceMount implements IMount {
|
||||
public final class ResourceMount implements Mount {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResourceMount.class);
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.filesystem.WritableMount;
|
||||
import dan200.computercraft.api.lua.ILuaAPI;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.core.apis.IAPIEnvironment;
|
||||
@@ -245,7 +245,7 @@ public class ServerComputer implements InputHandler, ComputerEnvironment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IWritableMount createRootMount() {
|
||||
return ComputerCraftAPI.createSaveDirMount(level, "computer/" + computer.getID(), Config.computerSpaceLimit);
|
||||
public @Nullable WritableMount createRootMount() {
|
||||
return ComputerCraftAPI.createSaveDirMount(level.getServer(), "computer/" + computer.getID(), Config.computerSpaceLimit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.core.ComputerContext;
|
||||
import dan200.computercraft.core.computer.ComputerThread;
|
||||
import dan200.computercraft.core.computer.GlobalEnvironment;
|
||||
@@ -21,7 +21,6 @@ import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -156,7 +155,7 @@ public final class ServerContext {
|
||||
*
|
||||
* @param kind The kind we're assigning an ID for, for instance {@code "computer"} or {@code "peripheral.monitor"}.
|
||||
* @return The next available ID.
|
||||
* @see ComputerCraftAPI#createUniqueNumberedSaveDir(Level, String)
|
||||
* @see ComputerCraftAPI#createUniqueNumberedSaveDir(MinecraftServer, String)
|
||||
*/
|
||||
public int getNextId(String kind) {
|
||||
return idAssigner.getNextId(kind);
|
||||
@@ -183,8 +182,8 @@ public final class ServerContext {
|
||||
|
||||
private record Environment(MinecraftServer server) implements GlobalEnvironment {
|
||||
@Override
|
||||
public @Nullable IMount createResourceMount(String domain, String subPath) {
|
||||
return ComputerCraftAPI.createResourceMount(domain, subPath);
|
||||
public @Nullable Mount createResourceMount(String domain, String subPath) {
|
||||
return ComputerCraftAPI.createResourceMount(server, domain, subPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
package dan200.computercraft.shared.computer.items;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.shared.computer.blocks.AbstractComputerBlock;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
@@ -63,12 +64,12 @@ public abstract class AbstractComputerItem extends BlockItem implements ICompute
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IMount createDataMount(ItemStack stack, Level world) {
|
||||
public @Nullable Mount createDataMount(ItemStack stack, ServerLevel level) {
|
||||
var family = getFamily();
|
||||
if (family != ComputerFamily.COMMAND) {
|
||||
var id = getComputerID(stack);
|
||||
if (id >= 0) {
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, Config.computerSpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(level.getServer(), "computer/" + id, Config.computerSpaceLimit);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -9,7 +9,7 @@ import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.impl.PocketUpgrades;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
@@ -245,7 +245,7 @@ public class UpgradeRecipeGenerator<T> {
|
||||
final Ingredient ingredient;
|
||||
final @Nullable ITurtleUpgrade turtle;
|
||||
final @Nullable IPocketUpgrade pocket;
|
||||
final IUpgradeBase upgrade;
|
||||
final UpgradeBase upgrade;
|
||||
private @Nullable ArrayList<T> recipes;
|
||||
|
||||
UpgradeInfo(ItemStack stack, ITurtleUpgrade turtle) {
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -83,13 +84,13 @@ public class DiskItem extends Item implements IMedia, IColouredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IMount createDataMount(ItemStack stack, Level world) {
|
||||
public @Nullable Mount createDataMount(ItemStack stack, ServerLevel level) {
|
||||
var diskID = getDiskID(stack);
|
||||
if (diskID < 0) {
|
||||
diskID = ComputerCraftAPI.createUniqueNumberedSaveDir(world, "disk");
|
||||
diskID = ComputerCraftAPI.createUniqueNumberedSaveDir(level.getServer(), "disk");
|
||||
setDiskID(stack, diskID);
|
||||
}
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "disk/" + diskID, Config.floppySpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(level.getServer(), "disk/" + diskID, Config.floppySpaceLimit);
|
||||
}
|
||||
|
||||
public static int getDiskID(ItemStack stack) {
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.media.items;
|
||||
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.core.filesystem.SubMount;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
@@ -15,6 +15,7 @@ import dan200.computercraft.shared.ModRegistry;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
@@ -57,8 +58,8 @@ public class TreasureDiskItem extends Item implements IMedia {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IMount createDataMount(ItemStack stack, Level world) {
|
||||
var rootTreasure = getTreasureMount();
|
||||
public @Nullable Mount createDataMount(ItemStack stack, ServerLevel level) {
|
||||
var rootTreasure = ComputerCraftAPI.createResourceMount(level.getServer(), "computercraft", "lua/treasure");
|
||||
if (rootTreasure == null) return null;
|
||||
|
||||
var subPath = getSubPath(stack);
|
||||
@@ -93,10 +94,6 @@ public class TreasureDiskItem extends Item implements IMedia {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static @Nullable IMount getTreasureMount() {
|
||||
return ComputerCraftAPI.createResourceMount("computercraft", "lua/treasure");
|
||||
}
|
||||
|
||||
private static String getTitle(ItemStack stack) {
|
||||
var nbt = stack.getTag();
|
||||
return nbt != null && nbt.contains(NBT_TITLE) ? nbt.getString(NBT_TITLE) : "'missingno' by how did you get this anyway?";
|
||||
|
||||
@@ -9,7 +9,7 @@ import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeSerialiser;
|
||||
import dan200.computercraft.impl.PocketUpgrades;
|
||||
import dan200.computercraft.impl.TurtleUpgrades;
|
||||
@@ -42,7 +42,7 @@ public class UpgradesLoadedMessage implements NetworkMessage<ClientNetworkContex
|
||||
pocketUpgrades = fromBytes(buf, PocketUpgradeSerialiser.REGISTRY_ID);
|
||||
}
|
||||
|
||||
private <R extends UpgradeSerialiser<? extends T>, T extends IUpgradeBase> Map<String, UpgradeManager.UpgradeWrapper<R, T>> fromBytes(
|
||||
private <R extends UpgradeSerialiser<? extends T>, T extends UpgradeBase> Map<String, UpgradeManager.UpgradeWrapper<R, T>> fromBytes(
|
||||
FriendlyByteBuf buf, ResourceKey<Registry<R>> registryKey
|
||||
) {
|
||||
var registry = PlatformHelper.get().wrap(registryKey);
|
||||
@@ -71,7 +71,7 @@ public class UpgradesLoadedMessage implements NetworkMessage<ClientNetworkContex
|
||||
toBytes(buf, PocketUpgradeSerialiser.REGISTRY_ID, pocketUpgrades);
|
||||
}
|
||||
|
||||
private <R extends UpgradeSerialiser<? extends T>, T extends IUpgradeBase> void toBytes(
|
||||
private <R extends UpgradeSerialiser<? extends T>, T extends UpgradeBase> void toBytes(
|
||||
FriendlyByteBuf buf, ResourceKey<Registry<R>> registryKey, Map<String, UpgradeManager.UpgradeWrapper<R, T>> upgrades
|
||||
) {
|
||||
var registry = PlatformHelper.get().wrap(registryKey);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.filesystem.WritableMount;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.common.AbstractContainerBlockEntity;
|
||||
@@ -205,7 +205,7 @@ public final class DiskDriveBlockEntity extends AbstractContainerBlockEntity {
|
||||
private void mountDisk(IComputerAccess computer, MountInfo info, MediaStack disk) {
|
||||
var mount = disk.getMount((ServerLevel) getLevel());
|
||||
if (mount != null) {
|
||||
if (mount instanceof IWritableMount writable) {
|
||||
if (mount instanceof WritableMount writable) {
|
||||
// Try mounting at the lowest numbered "disk" name we can
|
||||
var n = 1;
|
||||
while (info.mountPath == null) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.diskdrive;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.impl.MediaProviders;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -24,7 +24,7 @@ class MediaStack {
|
||||
final @Nullable IMedia media;
|
||||
|
||||
@Nullable
|
||||
private IMount mount;
|
||||
private Mount mount;
|
||||
|
||||
MediaStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
@@ -42,7 +42,7 @@ class MediaStack {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IMount getMount(ServerLevel level) {
|
||||
public Mount getMount(ServerLevel level) {
|
||||
if (media == null) return null;
|
||||
|
||||
if (mount == null) mount = media.createDataMount(stack, level);
|
||||
|
||||
@@ -7,10 +7,10 @@ package dan200.computercraft.shared.peripheral.modem;
|
||||
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.lua.LuaFunction;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.IPacketReceiver;
|
||||
import dan200.computercraft.api.network.IPacketSender;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.network.PacketNetwork;
|
||||
import dan200.computercraft.api.network.PacketReceiver;
|
||||
import dan200.computercraft.api.network.PacketSender;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
@@ -83,8 +83,8 @@ import java.util.Set;
|
||||
* <mc-recipe recipe="computercraft:wired_modem_full_from"></mc-recipe>
|
||||
* </div>
|
||||
*/
|
||||
public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPacketReceiver {
|
||||
private @Nullable IPacketNetwork network;
|
||||
public abstract class ModemPeripheral implements IPeripheral, PacketSender, PacketReceiver {
|
||||
private @Nullable PacketNetwork network;
|
||||
private final Set<IComputerAccess> computers = new HashSet<>(1);
|
||||
private final ModemState state;
|
||||
|
||||
@@ -96,7 +96,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa
|
||||
return state;
|
||||
}
|
||||
|
||||
private synchronized void setNetwork(@Nullable IPacketNetwork network) {
|
||||
private synchronized void setNetwork(@Nullable PacketNetwork network) {
|
||||
if (this.network == network) return;
|
||||
|
||||
// Leave old network
|
||||
@@ -137,7 +137,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract IPacketNetwork getNetwork();
|
||||
protected abstract PacketNetwork getNetwork();
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.command.text.ChatHelpers;
|
||||
@@ -67,7 +67,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
private boolean connectionsFormed = false;
|
||||
|
||||
private final WiredModemElement cable = new CableElement();
|
||||
private final IWiredNode node = cable.getNode();
|
||||
private final WiredNode node = cable.getNode();
|
||||
private final TickScheduler.Token tickToken = new TickScheduler.Token(this);
|
||||
private final WiredModemPeripheral modem = new WiredModemPeripheral(
|
||||
new ModemState(() -> TickScheduler.schedule(tickToken)),
|
||||
@@ -89,7 +89,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
}
|
||||
};
|
||||
|
||||
private final ComponentAccess<IWiredElement> connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged());
|
||||
private final ComponentAccess<WiredElement> connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged());
|
||||
|
||||
public CableBlockEntity(BlockEntityType<? extends CableBlockEntity> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -309,7 +309,7 @@ public class CableBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IWiredElement getWiredElement(@Nullable Direction direction) {
|
||||
public WiredElement getWiredElement(@Nullable Direction direction) {
|
||||
return direction == null || CableBlock.canConnectIn(getBlockState(), direction) ? cable : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetworkChange;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNetworkChange;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class WiredModemElement implements IWiredElement {
|
||||
private final IWiredNode node = ComputerCraftAPI.createWiredNodeForElement(this);
|
||||
public abstract class WiredModemElement implements WiredElement {
|
||||
private final WiredNode node = ComputerCraftAPI.createWiredNodeForElement(this);
|
||||
private final Map<String, IPeripheral> remotePeripherals = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public IWiredNode getNode() {
|
||||
public WiredNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class WiredModemElement implements IWiredElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkChanged(IWiredNetworkChange change) {
|
||||
public void networkChanged(WiredNetworkChange change) {
|
||||
synchronized (remotePeripherals) {
|
||||
remotePeripherals.keySet().removeAll(change.peripheralsRemoved().keySet());
|
||||
for (var name : change.peripheralsRemoved().keySet()) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.command.text.ChatHelpers;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
@@ -81,9 +81,9 @@ public class WiredModemFullBlockEntity extends BlockEntity {
|
||||
private final TickScheduler.Token tickToken = new TickScheduler.Token(this);
|
||||
private final ModemState modemState = new ModemState(() -> TickScheduler.schedule(tickToken));
|
||||
private final WiredModemElement element = new FullElement(this);
|
||||
private final IWiredNode node = element.getNode();
|
||||
private final WiredNode node = element.getNode();
|
||||
|
||||
private final ComponentAccess<IWiredElement> connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged());
|
||||
private final ComponentAccess<WiredElement> connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged());
|
||||
|
||||
private int invalidSides = 0;
|
||||
|
||||
@@ -278,7 +278,7 @@ public class WiredModemFullBlockEntity extends BlockEntity {
|
||||
node.updatePeripherals(peripherals);
|
||||
}
|
||||
|
||||
public IWiredElement getElement() {
|
||||
public WiredElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wired;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.filesystem.WritableMount;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.IWiredSender;
|
||||
import dan200.computercraft.api.network.PacketNetwork;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredSender;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.peripheral.IWorkMonitor;
|
||||
import dan200.computercraft.api.peripheral.NotAttachedException;
|
||||
import dan200.computercraft.api.peripheral.WorkMonitor;
|
||||
import dan200.computercraft.core.apis.PeripheralAPI;
|
||||
import dan200.computercraft.core.asm.PeripheralMethod;
|
||||
import dan200.computercraft.core.util.LuaUtil;
|
||||
@@ -30,7 +30,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public abstract class WiredModemPeripheral extends ModemPeripheral implements IWiredSender {
|
||||
public abstract class WiredModemPeripheral extends ModemPeripheral implements WiredSender {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WiredModemPeripheral.class);
|
||||
|
||||
private final WiredModemElement modem;
|
||||
@@ -54,7 +54,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPacketNetwork getNetwork() {
|
||||
protected PacketNetwork getNetwork() {
|
||||
return modem.getNode();
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
//endregion
|
||||
|
||||
@Override
|
||||
public IWiredNode getNode() {
|
||||
public WiredNode getNode() {
|
||||
return modem.getNode();
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
// IComputerAccess implementation
|
||||
|
||||
@Override
|
||||
public synchronized @Nullable String mount(String desiredLocation, IMount mount) {
|
||||
public synchronized @Nullable String mount(String desiredLocation, Mount mount) {
|
||||
if (!attached) throw new NotAttachedException();
|
||||
var mounted = computer.mount(desiredLocation, mount, name);
|
||||
mounts.add(mounted);
|
||||
@@ -376,7 +376,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized @Nullable String mount(String desiredLocation, IMount mount, String driveName) {
|
||||
public synchronized @Nullable String mount(String desiredLocation, Mount mount, String driveName) {
|
||||
if (!attached) throw new NotAttachedException();
|
||||
var mounted = computer.mount(desiredLocation, mount, driveName);
|
||||
mounts.add(mounted);
|
||||
@@ -384,7 +384,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized @Nullable String mountWritable(String desiredLocation, IWritableMount mount) {
|
||||
public synchronized @Nullable String mountWritable(String desiredLocation, WritableMount mount) {
|
||||
if (!attached) throw new NotAttachedException();
|
||||
var mounted = computer.mountWritable(desiredLocation, mount, name);
|
||||
mounts.add(mounted);
|
||||
@@ -392,7 +392,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized @Nullable String mountWritable(String desiredLocation, IWritableMount mount, String driveName) {
|
||||
public synchronized @Nullable String mountWritable(String desiredLocation, WritableMount mount, String driveName) {
|
||||
if (!attached) throw new NotAttachedException();
|
||||
var mounted = computer.mountWritable(desiredLocation, mount, driveName);
|
||||
mounts.add(mounted);
|
||||
@@ -419,7 +419,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkMonitor getMainThreadMonitor() {
|
||||
public WorkMonitor getMainThreadMonitor() {
|
||||
if (!attached) throw new NotAttachedException();
|
||||
return computer.getMainThreadMonitor();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.PacketNetwork;
|
||||
import dan200.computercraft.core.util.Nullability;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
@@ -51,7 +52,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IPacketNetwork getNetwork() {
|
||||
return ComputerCraftAPI.getWirelessNetwork();
|
||||
protected PacketNetwork getNetwork() {
|
||||
return ComputerCraftAPI.getWirelessNetwork(Nullability.assertNonNull(getLevel().getServer()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.peripheral.modem.wireless;
|
||||
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.api.network.IPacketReceiver;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.network.PacketNetwork;
|
||||
import dan200.computercraft.api.network.PacketReceiver;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
@@ -15,7 +15,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class WirelessNetwork implements IPacketNetwork {
|
||||
public class WirelessNetwork implements PacketNetwork {
|
||||
// TODO: Move this to ServerContext.
|
||||
private static @Nullable WirelessNetwork universalNetwork = null;
|
||||
|
||||
@@ -28,16 +28,16 @@ public class WirelessNetwork implements IPacketNetwork {
|
||||
universalNetwork = null;
|
||||
}
|
||||
|
||||
private final Set<IPacketReceiver> receivers = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
private final Set<PacketReceiver> receivers = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
||||
@Override
|
||||
public void addReceiver(IPacketReceiver receiver) {
|
||||
public void addReceiver(PacketReceiver receiver) {
|
||||
Objects.requireNonNull(receiver, "device cannot be null");
|
||||
receivers.add(receiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeReceiver(IPacketReceiver receiver) {
|
||||
public void removeReceiver(PacketReceiver receiver) {
|
||||
Objects.requireNonNull(receiver, "device cannot be null");
|
||||
receivers.remove(receiver);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class WirelessNetwork implements IPacketNetwork {
|
||||
for (var device : receivers) tryTransmit(device, packet, 0, true);
|
||||
}
|
||||
|
||||
private static void tryTransmit(IPacketReceiver receiver, Packet packet, double range, boolean interdimensional) {
|
||||
private static void tryTransmit(PacketReceiver receiver, Packet packet, double range, boolean interdimensional) {
|
||||
var sender = packet.sender();
|
||||
if (receiver.getLevel() == sender.getLevel()) {
|
||||
var receiveRange = Math.max(range, receiver.getRange()); // Ensure range is symmetrical
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.platform;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import dan200.computercraft.shared.network.client.ClientNetworkContext;
|
||||
@@ -45,7 +45,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
@@ -204,7 +203,7 @@ public interface PlatformHelper extends dan200.computercraft.impl.PlatformHelper
|
||||
* include all changes, and so block updates should still be listened to.
|
||||
* @return The peripheral component access.
|
||||
*/
|
||||
ComponentAccess<IWiredElement> createWiredElementAccess(Consumer<Direction> invalidate);
|
||||
ComponentAccess<WiredElement> createWiredElementAccess(Consumer<Direction> invalidate);
|
||||
|
||||
/**
|
||||
* Determine if there is a wired element in the given direction. This is equivalent to
|
||||
@@ -239,18 +238,6 @@ public interface PlatformHelper extends dan200.computercraft.impl.PlatformHelper
|
||||
@Nullable
|
||||
ContainerTransfer getContainer(ServerLevel level, BlockPos pos, Direction side);
|
||||
|
||||
/**
|
||||
* Wrap a vanilla Minecraft {@link Container} into Forge's {@link IItemHandlerModifiable}.
|
||||
*
|
||||
* @param container The container to wrap.
|
||||
* @return The item handler.
|
||||
* @deprecated This is only needed for backwards compatibility, and will be removed in 1.19.3.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default IItemHandlerModifiable wrapContainerToItemHandler(Container container) {
|
||||
throw new UnsupportedOperationException("Can only create IItemHandlerModifiable on Forge");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link RecipeIngredients} for this loader.
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.pocket.items;
|
||||
import com.google.common.base.Objects;
|
||||
import dan200.computercraft.annotations.ForgeOverride;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.media.IMedia;
|
||||
import dan200.computercraft.api.pocket.IPocketUpgrade;
|
||||
import dan200.computercraft.core.computer.ComputerSide;
|
||||
@@ -192,21 +192,19 @@ public class PocketComputerItem extends Item implements IComputerItem, IMedia, I
|
||||
return ComputerCraftAPI.MOD_ID;
|
||||
}
|
||||
|
||||
public PocketServerComputer createServerComputer(ServerLevel world, Entity entity, @Nullable Container inventory, ItemStack stack) {
|
||||
if (world.isClientSide) throw new IllegalStateException("Cannot call createServerComputer on the client");
|
||||
|
||||
public PocketServerComputer createServerComputer(ServerLevel level, Entity entity, @Nullable Container inventory, ItemStack stack) {
|
||||
var sessionID = getSessionID(stack);
|
||||
|
||||
var registry = ServerContext.get(world.getServer()).registry();
|
||||
var registry = ServerContext.get(level.getServer()).registry();
|
||||
var computer = (PocketServerComputer) registry.get(sessionID, getInstanceID(stack));
|
||||
if (computer == null) {
|
||||
var computerID = getComputerID(stack);
|
||||
if (computerID < 0) {
|
||||
computerID = ComputerCraftAPI.createUniqueNumberedSaveDir(world, IDAssigner.COMPUTER);
|
||||
computerID = ComputerCraftAPI.createUniqueNumberedSaveDir(level.getServer(), IDAssigner.COMPUTER);
|
||||
setComputerID(stack, computerID);
|
||||
}
|
||||
|
||||
computer = new PocketServerComputer(world, entity.blockPosition(), getComputerID(stack), getLabel(stack), getFamily());
|
||||
computer = new PocketServerComputer(level, entity.blockPosition(), getComputerID(stack), getLabel(stack), getFamily());
|
||||
|
||||
setInstanceID(stack, computer.register());
|
||||
setSessionID(stack, registry.getSessionID());
|
||||
@@ -219,7 +217,7 @@ public class PocketComputerItem extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
if (inventory != null) inventory.setChanged();
|
||||
}
|
||||
computer.setLevel(world);
|
||||
computer.setLevel(level);
|
||||
return computer;
|
||||
}
|
||||
|
||||
@@ -265,10 +263,10 @@ public class PocketComputerItem extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IMount createDataMount(ItemStack stack, Level world) {
|
||||
public @Nullable Mount createDataMount(ItemStack stack, ServerLevel level) {
|
||||
var id = getComputerID(stack);
|
||||
if (id >= 0) {
|
||||
return ComputerCraftAPI.createSaveDirMount(world, "computer/" + id, Config.computerSpaceLimit);
|
||||
return ComputerCraftAPI.createSaveDirMount(level.getServer(), "computer/" + id, Config.computerSpaceLimit);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.turtle.apis;
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.core.apis.IAPIEnvironment;
|
||||
@@ -82,7 +82,7 @@ public class TurtleAPI implements ILuaAPI {
|
||||
return new String[]{ "turtle" };
|
||||
}
|
||||
|
||||
private MethodResult trackCommand(ITurtleCommand command) {
|
||||
private MethodResult trackCommand(TurtleCommand command) {
|
||||
environment.observe(Metrics.TURTLE_OPS);
|
||||
return turtle.executeCommand(command);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.container.InventoryDelegate;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity;
|
||||
import dan200.computercraft.shared.util.BlockEntityHelpers;
|
||||
import dan200.computercraft.shared.util.Holiday;
|
||||
@@ -39,7 +38,6 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
@@ -382,12 +380,6 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated(forRemoval = true)
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return PlatformHelper.get().wrapContainerToItemHandler(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFuelNeeded() {
|
||||
return Config.turtlesNeedFuel;
|
||||
@@ -436,7 +428,7 @@ public class TurtleBrain implements ITurtleAccess {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodResult executeCommand(ITurtleCommand command) {
|
||||
public MethodResult executeCommand(TurtleCommand command) {
|
||||
if (getLevel().isClientSide) throw new UnsupportedOperationException("Cannot run commands on the client");
|
||||
if (commandQueue.size() > 16) return MethodResult.of(false, "Too many ongoing turtle commands");
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
|
||||
public record TurtleCommandQueueEntry(int callbackID, ITurtleCommand command) {
|
||||
public record TurtleCommandQueueEntry(int callbackID, TurtleCommand command) {
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class TurtleCompareCommand implements ITurtleCommand {
|
||||
public class TurtleCompareCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
|
||||
public TurtleCompareCommand(InteractDirection direction) {
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class TurtleCompareToCommand implements ITurtleCommand {
|
||||
public class TurtleCompareToCommand implements TurtleCommand {
|
||||
private final int slot;
|
||||
|
||||
public TurtleCompareToCommand(int slot) {
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import dan200.computercraft.shared.turtle.upgrades.TurtleInventoryCrafting;
|
||||
|
||||
public class TurtleCraftCommand implements ITurtleCommand {
|
||||
public class TurtleCraftCommand implements TurtleCommand {
|
||||
private final int limit;
|
||||
|
||||
public TurtleCraftCommand(int limit) {
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
|
||||
public class TurtleDetectCommand implements ITurtleCommand {
|
||||
public class TurtleDetectCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
|
||||
public TurtleDetectCommand(InteractDirection direction) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.platform.ContainerTransfer;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
@@ -16,7 +16,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.LevelEvent;
|
||||
|
||||
public class TurtleDropCommand implements ITurtleCommand {
|
||||
public class TurtleDropCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
private final int quantity;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import dan200.computercraft.impl.TurtleUpgrades;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class TurtleEquipCommand implements ITurtleCommand {
|
||||
public class TurtleEquipCommand implements TurtleCommand {
|
||||
private final TurtleSide side;
|
||||
|
||||
public TurtleEquipCommand(TurtleSide side) {
|
||||
|
||||
@@ -8,10 +8,10 @@ package dan200.computercraft.shared.turtle.core;
|
||||
import dan200.computercraft.api.detail.BlockReference;
|
||||
import dan200.computercraft.api.detail.VanillaDetailRegistries;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
|
||||
public class TurtleInspectCommand implements ITurtleCommand {
|
||||
public class TurtleInspectCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
|
||||
public TurtleInspectCommand(InteractDirection direction) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.config.Config;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class TurtleMoveCommand implements ITurtleCommand {
|
||||
public class TurtleMoveCommand implements TurtleCommand {
|
||||
private final MoveDirection direction;
|
||||
|
||||
public TurtleMoveCommand(MoveDirection direction) {
|
||||
|
||||
@@ -7,8 +7,8 @@ package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
import dan200.computercraft.shared.turtle.TurtleUtil;
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TurtlePlaceCommand implements ITurtleCommand {
|
||||
public class TurtlePlaceCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
private final Object[] extraArguments;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.impl.TurtleRefuelHandlers;
|
||||
|
||||
public class TurtleRefuelCommand implements ITurtleCommand {
|
||||
public class TurtleRefuelCommand implements TurtleCommand {
|
||||
private final int limit;
|
||||
|
||||
public TurtleRefuelCommand(int limit) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.platform.ContainerTransfer;
|
||||
import dan200.computercraft.shared.platform.PlatformHelper;
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.LevelEvent;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
public class TurtleSuckCommand implements ITurtleCommand {
|
||||
public class TurtleSuckCommand implements TurtleCommand {
|
||||
private final InteractDirection direction;
|
||||
private final int quantity;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import dan200.computercraft.api.turtle.*;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TurtleToolCommand implements ITurtleCommand {
|
||||
public class TurtleToolCommand implements TurtleCommand {
|
||||
private final TurtleVerb verb;
|
||||
private final InteractDirection direction;
|
||||
private final @Nullable TurtleSide side;
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
|
||||
public class TurtleTransferToCommand implements ITurtleCommand {
|
||||
public class TurtleTransferToCommand implements TurtleCommand {
|
||||
private final int slot;
|
||||
private final int quantity;
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
package dan200.computercraft.shared.turtle.core;
|
||||
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
|
||||
public class TurtleTurnCommand implements ITurtleCommand {
|
||||
public class TurtleTurnCommand implements TurtleCommand {
|
||||
private final TurnDirection direction;
|
||||
|
||||
public TurtleTurnCommand(TurnDirection direction) {
|
||||
|
||||
@@ -7,7 +7,7 @@ package dan200.computercraft.shared.turtle.upgrades;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
|
||||
import dan200.computercraft.api.upgrades.IUpgradeBase;
|
||||
import dan200.computercraft.api.upgrades.UpgradeBase;
|
||||
import dan200.computercraft.shared.platform.Registries;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
@@ -25,7 +25,7 @@ public final class TurtleToolSerialiser implements TurtleUpgradeSerialiser<Turtl
|
||||
|
||||
@Override
|
||||
public TurtleTool fromJson(ResourceLocation id, JsonObject object) {
|
||||
var adjective = GsonHelper.getAsString(object, "adjective", IUpgradeBase.getDefaultAdjective(id));
|
||||
var adjective = GsonHelper.getAsString(object, "adjective", UpgradeBase.getDefaultAdjective(id));
|
||||
var toolItem = GsonHelper.getAsItem(object, "item");
|
||||
var craftingItem = GsonHelper.getAsItem(object, "craftingItem", toolItem);
|
||||
var damageMultiplier = GsonHelper.getAsFloat(object, "damageMultiplier", 3.0f);
|
||||
|
||||
@@ -8,8 +8,8 @@ package dan200.computercraft;
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.impl.AbstractComputerCraftAPI;
|
||||
import dan200.computercraft.impl.ComputerCraftAPIService;
|
||||
@@ -139,7 +139,7 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentAccess<IWiredElement> createWiredElementAccess(Consumer<Direction> invalidate) {
|
||||
public ComponentAccess<WiredElement> createWiredElementAccess(Consumer<Direction> invalidate) {
|
||||
throw new UnsupportedOperationException("Cannot interact with the world inside tests");
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMount createResourceMount(String domain, String subPath) {
|
||||
public Mount createResourceMount(MinecraftServer server, String domain, String subPath) {
|
||||
throw new UnsupportedOperationException("Cannot create resource mount");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ package dan200.computercraft.impl.network.wired;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import dan200.computercraft.api.network.wired.IWiredElement;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetworkChange;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.network.wired.WiredElement;
|
||||
import dan200.computercraft.api.network.wired.WiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.WiredNetworkChange;
|
||||
import dan200.computercraft.api.network.wired.WiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -36,7 +36,7 @@ public class NetworkTest {
|
||||
bE = new NetworkElement(null, null, "b"),
|
||||
cE = new NetworkElement(null, null, "c");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
cN = cE.getNode();
|
||||
@@ -76,7 +76,7 @@ public class NetworkTest {
|
||||
bE = new NetworkElement(null, null, "b"),
|
||||
cE = new NetworkElement(null, null, "c");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
cN = cE.getNode();
|
||||
@@ -103,7 +103,7 @@ public class NetworkTest {
|
||||
bE = new NetworkElement(null, null, "b"),
|
||||
cE = new NetworkElement(null, null, "c");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
cN = cE.getNode();
|
||||
@@ -131,7 +131,7 @@ public class NetworkTest {
|
||||
bE = new NetworkElement(null, null, "b"),
|
||||
bbE = new NetworkElement(null, null, "b_");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
aaN = aaE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
@@ -172,7 +172,7 @@ public class NetworkTest {
|
||||
bE = new NetworkElement(null, null, "b"),
|
||||
cE = new NetworkElement(null, null, "c");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
cN = cE.getNode();
|
||||
@@ -203,7 +203,7 @@ public class NetworkTest {
|
||||
bbE = new NetworkElement(null, null, "b_"),
|
||||
cE = new NetworkElement(null, null, "c");
|
||||
|
||||
IWiredNode
|
||||
WiredNode
|
||||
aN = aE.getNode(),
|
||||
aaN = aaE.getNode(),
|
||||
bN = bE.getNode(),
|
||||
@@ -238,7 +238,7 @@ public class NetworkTest {
|
||||
@Test
|
||||
@Disabled("Takes a long time to run, mostly for stress testing")
|
||||
public void testLarge() {
|
||||
var grid = new Grid<IWiredNode>(BRUTE_SIZE);
|
||||
var grid = new Grid<WiredNode>(BRUTE_SIZE);
|
||||
grid.map((existing, pos) -> new NetworkElement(null, null, "n_" + pos).getNode());
|
||||
|
||||
// Test connecting
|
||||
@@ -297,11 +297,11 @@ public class NetworkTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class NetworkElement implements IWiredElement {
|
||||
private static final class NetworkElement implements WiredElement {
|
||||
private final Level world;
|
||||
private final Vec3 position;
|
||||
private final String id;
|
||||
private final IWiredNode node;
|
||||
private final WiredNode node;
|
||||
private final Map<String, IPeripheral> localPeripherals = Maps.newHashMap();
|
||||
private final Map<String, IPeripheral> remotePeripherals = Maps.newHashMap();
|
||||
|
||||
@@ -334,12 +334,12 @@ public class NetworkTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWiredNode getNode() {
|
||||
public WiredNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkChanged(IWiredNetworkChange change) {
|
||||
public void networkChanged(WiredNetworkChange change) {
|
||||
remotePeripherals.keySet().removeAll(change.peripheralsRemoved().keySet());
|
||||
remotePeripherals.putAll(change.peripheralsAdded());
|
||||
}
|
||||
@@ -406,11 +406,11 @@ public class NetworkTest {
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<WiredNode> nodes(IWiredNetwork network) {
|
||||
return ((WiredNetwork) network).nodes;
|
||||
private static Set<WiredNodeImpl> nodes(WiredNetwork network) {
|
||||
return ((WiredNetworkImpl) network).nodes;
|
||||
}
|
||||
|
||||
private static Set<WiredNode> neighbours(IWiredNode node) {
|
||||
return ((WiredNode) node).neighbours;
|
||||
private static Set<WiredNodeImpl> neighbours(WiredNode node) {
|
||||
return ((WiredNodeImpl) node).neighbours;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.computer.core;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.Mount;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.server.packs.FolderPackResources;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class ResourceMountTest {
|
||||
private IMount mount;
|
||||
private Mount mount;
|
||||
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
|
||||
Reference in New Issue
Block a user