From 87c6d3aef694917923436c026362acf14136c7be Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 3 Dec 2022 15:02:00 +0000 Subject: [PATCH] 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. --- projects/common-api/build.gradle.kts | 1 - .../computercraft/api/ComputerCraftAPI.java | 142 ++++++----------- .../api/detail/BasicItemDetailProvider.java | 2 +- ...etailProvider.java => DetailProvider.java} | 2 +- .../api/detail/DetailRegistry.java | 4 +- .../computercraft/api/media/IMedia.java | 23 +-- ...IMediaProvider.java => MediaProvider.java} | 6 +- .../computercraft/api/network/Packet.java | 14 +- ...IPacketNetwork.java => PacketNetwork.java} | 12 +- ...acketReceiver.java => PacketReceiver.java} | 16 +- .../{IPacketSender.java => PacketSender.java} | 4 +- .../{IWiredElement.java => WiredElement.java} | 10 +- .../{IWiredNetwork.java => WiredNetwork.java} | 30 ++-- ...orkChange.java => WiredNetworkChange.java} | 4 +- .../wired/{IWiredNode.java => WiredNode.java} | 26 ++-- .../{IWiredSender.java => WiredSender.java} | 10 +- .../api/pocket/AbstractPocketUpgrade.java | 4 +- .../api/pocket/IPocketUpgrade.java | 4 +- .../api/pocket/PocketUpgradeSerialiser.java | 18 +-- ...ider.java => BundledRedstoneProvider.java} | 8 +- .../api/turtle/AbstractTurtleUpgrade.java | 4 +- .../api/turtle/ITurtleAccess.java | 21 +-- .../api/turtle/ITurtleUpgrade.java | 4 +- ...ITurtleCommand.java => TurtleCommand.java} | 8 +- .../api/turtle/TurtleCommandResult.java | 2 +- .../api/turtle/TurtleUpgradeSerialiser.java | 18 +-- .../{IUpgradeBase.java => UpgradeBase.java} | 2 +- .../api/upgrades/UpgradeDataProvider.java | 2 +- .../api/upgrades/UpgradeSerialiser.java | 6 +- .../impl/ComputerCraftAPIService.java | 52 ++----- .../upgrades/SerialiserWithCraftingItem.java | 4 +- .../impl/upgrades/SimpleSerialiser.java | 4 +- projects/common/build.gradle.kts | 2 - .../computercraft/data/LanguageProvider.java | 6 +- .../impl/AbstractComputerCraftAPI.java | 52 ++----- .../computercraft/impl/BundledRedstone.java | 6 +- .../computercraft/impl/MediaProviders.java | 6 +- .../computercraft/impl/UpgradeManager.java | 6 +- .../impl/detail/DetailRegistryImpl.java | 10 +- .../impl/network/wired/InvariantChecker.java | 4 +- ...hange.java => WiredNetworkChangeImpl.java} | 30 ++-- ...iredNetwork.java => WiredNetworkImpl.java} | 74 ++++----- .../{WiredNode.java => WiredNodeImpl.java} | 40 ++--- .../computercraft/shared/ModRegistry.java | 4 +- .../DefaultBundledRedstoneProvider.java | 4 +- .../blocks/AbstractComputerBlockEntity.java | 2 +- .../shared/computer/core/ResourceMount.java | 4 +- .../shared/computer/core/ServerComputer.java | 6 +- .../shared/computer/core/ServerContext.java | 9 +- .../computer/items/AbstractComputerItem.java | 7 +- .../integration/UpgradeRecipeGenerator.java | 4 +- .../shared/media/items/DiskItem.java | 9 +- .../shared/media/items/TreasureDiskItem.java | 11 +- .../network/client/UpgradesLoadedMessage.java | 6 +- .../diskdrive/DiskDriveBlockEntity.java | 4 +- .../peripheral/diskdrive/MediaStack.java | 6 +- .../peripheral/modem/ModemPeripheral.java | 14 +- .../modem/wired/CableBlockEntity.java | 10 +- .../modem/wired/WiredModemElement.java | 14 +- .../wired/WiredModemFullBlockEntity.java | 10 +- .../modem/wired/WiredModemPeripheral.java | 28 ++-- .../wireless/WirelessModemPeripheral.java | 7 +- .../modem/wireless/WirelessNetwork.java | 14 +- .../shared/platform/PlatformHelper.java | 17 +- .../pocket/items/PocketComputerItem.java | 18 +-- .../shared/turtle/apis/TurtleAPI.java | 4 +- .../shared/turtle/core/TurtleBrain.java | 10 +- .../turtle/core/TurtleCommandQueueEntry.java | 4 +- .../turtle/core/TurtleCompareCommand.java | 4 +- .../turtle/core/TurtleCompareToCommand.java | 4 +- .../turtle/core/TurtleCraftCommand.java | 4 +- .../turtle/core/TurtleDetectCommand.java | 4 +- .../shared/turtle/core/TurtleDropCommand.java | 4 +- .../turtle/core/TurtleEquipCommand.java | 2 +- .../turtle/core/TurtleInspectCommand.java | 4 +- .../shared/turtle/core/TurtleMoveCommand.java | 4 +- .../turtle/core/TurtlePlaceCommand.java | 4 +- .../turtle/core/TurtleRefuelCommand.java | 4 +- .../shared/turtle/core/TurtleSuckCommand.java | 4 +- .../shared/turtle/core/TurtleToolCommand.java | 2 +- .../turtle/core/TurtleTransferToCommand.java | 4 +- .../shared/turtle/core/TurtleTurnCommand.java | 4 +- .../turtle/upgrades/TurtleToolSerialiser.java | 4 +- .../computercraft/TestPlatformHelper.java | 8 +- .../impl/network/wired/NetworkTest.java | 38 ++--- .../computer/core/ResourceMountTest.java | 4 +- projects/core-api/build.gradle.kts | 1 - .../api/filesystem/FileAttributes.java | 2 +- .../filesystem/FileOperationException.java | 2 +- .../api/filesystem/IFileSystem.java | 42 ----- .../filesystem/{IMount.java => Mount.java} | 8 +- ...IWritableMount.java => WritableMount.java} | 12 +- .../computercraft/api/lua/GenericSource.java | 7 +- .../api/lua/IComputerSystem.java | 9 -- .../computercraft/api/lua/ILuaContext.java | 4 +- .../computercraft/api/lua/LuaFunction.java | 2 +- .../api/lua/{ILuaTask.java => LuaTask.java} | 6 +- .../computercraft/api/lua/TaskCallback.java | 2 +- .../api/peripheral/IComputerAccess.java | 52 +++---- .../{IWorkMonitor.java => WorkMonitor.java} | 2 +- .../core/apis/ComputerAccess.java | 12 +- .../core/apis/IAPIEnvironment.java | 4 +- .../core/apis/PeripheralAPI.java | 12 +- .../computercraft/core/computer/Computer.java | 10 +- .../core/computer/ComputerEnvironment.java | 4 +- .../core/computer/ComputerExecutor.java | 10 +- .../core/computer/ComputerSystem.java | 8 - .../core/computer/Environment.java | 4 +- .../core/computer/GlobalEnvironment.java | 4 +- .../core/computer/LuaContext.java | 4 +- .../mainthread/MainThreadExecutor.java | 6 +- .../mainthread/MainThreadScheduler.java | 4 +- .../core/filesystem/FileMount.java | 4 +- .../core/filesystem/FileSystem.java | 18 +-- .../filesystem/FileSystemWrapperMount.java | 146 ------------------ .../core/filesystem/JarMount.java | 4 +- .../core/filesystem/MountWrapper.java | 12 +- .../core/filesystem/SubMount.java | 8 +- .../core/ComputerTestDelegate.java | 4 +- .../core/apis/ObjectWrapper.java | 2 +- .../computercraft/core/asm/GeneratorTest.java | 2 +- .../core/computer/ComputerBootstrap.java | 4 +- .../core/filesystem/FileMountTest.java | 6 +- .../core/filesystem/FileSystemTest.java | 6 +- .../core/filesystem/JarMountTest.java | 10 +- .../test/core/apis/BasicApiEnvironment.java | 4 +- .../test/core/computer/BasicEnvironment.java | 14 +- .../test/core/filesystem/MemoryMount.java | 4 +- projects/fabric-api/build.gradle.kts | 22 --- .../api/node/wired/WiredElementLookup.java | 8 +- projects/fabric/build.gradle.kts | 2 - .../impl/ComputerCraftAPIImpl.java | 9 +- .../computercraft/shared/ComputerCraft.java | 14 +- .../shared/details/FluidDetails.java | 4 +- .../generic/methods/InventoryMethods.java | 5 +- .../shared/platform/PlatformHelperImpl.java | 4 +- .../api/ForgeComputerCraftAPI.java | 8 +- .../api/peripheral/IPeripheralProvider.java | 0 .../api/turtle/event/TurtleEvent.java | 38 ----- .../api/turtle/event/TurtleRefuelEvent.java | 86 ----------- .../impl/ComputerCraftAPIForgeService.java | 9 +- projects/forge-stubs/build.gradle.kts | 8 - .../common/capabilities/Capability.java | 12 -- .../common/util/LazyOptional.java | 15 -- .../items/IItemHandlerModifiable.java | 10 -- .../registries/IForgeRegistry.java | 10 -- .../registries/RegistryManager.java | 18 --- .../dan200/computercraft/ComputerCraft.java | 18 +-- .../impl/ComputerCraftAPIImpl.java | 21 +-- .../computercraft/shared/Capabilities.java | 4 +- .../generic/methods/EnergyMethods.java | 5 +- .../generic/methods/FluidMethods.java | 5 +- .../generic/methods/InventoryMethods.java | 5 +- .../shared/platform/PlatformHelperImpl.java | 11 +- projects/mc-stubs/build.gradle.kts | 8 - .../minecraft/resources/ResourceLocation.java | 14 -- settings.gradle.kts | 2 - 157 files changed, 619 insertions(+), 1272 deletions(-) rename projects/common-api/src/main/java/dan200/computercraft/api/detail/{IDetailProvider.java => DetailProvider.java} (97%) rename projects/common-api/src/main/java/dan200/computercraft/api/media/{IMediaProvider.java => MediaProvider.java} (91%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/{IPacketNetwork.java => PacketNetwork.java} (85%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/{IPacketReceiver.java => PacketReceiver.java} (84%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/{IPacketSender.java => PacketSender.java} (90%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/wired/{IWiredElement.java => WiredElement.java} (78%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/wired/{IWiredNetwork.java => WiredNetwork.java} (78%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/wired/{IWiredNetworkChange.java => WiredNetworkChange.java} (91%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/wired/{IWiredNode.java => WiredNode.java} (82%) rename projects/common-api/src/main/java/dan200/computercraft/api/network/wired/{IWiredSender.java => WiredSender.java} (67%) rename projects/common-api/src/main/java/dan200/computercraft/api/redstone/{IBundledRedstoneProvider.java => BundledRedstoneProvider.java} (79%) rename projects/common-api/src/main/java/dan200/computercraft/api/turtle/{ITurtleCommand.java => TurtleCommand.java} (83%) rename projects/common-api/src/main/java/dan200/computercraft/api/upgrades/{IUpgradeBase.java => UpgradeBase.java} (99%) rename projects/common/src/main/java/dan200/computercraft/impl/network/wired/{WiredNetworkChange.java => WiredNetworkChangeImpl.java} (61%) rename projects/common/src/main/java/dan200/computercraft/impl/network/wired/{WiredNetwork.java => WiredNetworkImpl.java} (83%) rename projects/common/src/main/java/dan200/computercraft/impl/network/wired/{WiredNode.java => WiredNodeImpl.java} (70%) delete mode 100644 projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java rename projects/core-api/src/main/java/dan200/computercraft/api/filesystem/{IMount.java => Mount.java} (96%) rename projects/core-api/src/main/java/dan200/computercraft/api/filesystem/{IWritableMount.java => WritableMount.java} (91%) rename projects/core-api/src/main/java/dan200/computercraft/api/lua/{ILuaTask.java => LuaTask.java} (88%) rename projects/core-api/src/main/java/dan200/computercraft/api/peripheral/{IWorkMonitor.java => WorkMonitor.java} (98%) delete mode 100644 projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java rename projects/{common-api => forge-api}/src/main/java/dan200/computercraft/api/peripheral/IPeripheralProvider.java (100%) delete mode 100644 projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java delete mode 100644 projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java delete mode 100644 projects/forge-stubs/build.gradle.kts delete mode 100644 projects/forge-stubs/src/main/java/net/minecraftforge/common/capabilities/Capability.java delete mode 100644 projects/forge-stubs/src/main/java/net/minecraftforge/common/util/LazyOptional.java delete mode 100644 projects/forge-stubs/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java delete mode 100644 projects/forge-stubs/src/main/java/net/minecraftforge/registries/IForgeRegistry.java delete mode 100644 projects/forge-stubs/src/main/java/net/minecraftforge/registries/RegistryManager.java delete mode 100644 projects/mc-stubs/build.gradle.kts delete mode 100644 projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java diff --git a/projects/common-api/build.gradle.kts b/projects/common-api/build.gradle.kts index 024004852..40c39190f 100644 --- a/projects/common-api/build.gradle.kts +++ b/projects/common-api/build.gradle.kts @@ -10,7 +10,6 @@ java { dependencies { api(project(":core-api")) - compileOnly(project(":forge-stubs")) } tasks.javadoc { diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java b/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java index 94f44dbaa..90533ee19 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/ComputerCraftAPI.java @@ -5,31 +5,26 @@ */ package dan200.computercraft.api; -import dan200.computercraft.api.detail.BlockReference; -import dan200.computercraft.api.detail.DetailRegistry; -import dan200.computercraft.api.detail.IDetailProvider; -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.GenericSource; +import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.lua.ILuaAPIFactory; import dan200.computercraft.api.media.IMedia; -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.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.peripheral.IComputerAccess; -import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.peripheral.IPeripheralProvider; -import dan200.computercraft.api.redstone.IBundledRedstoneProvider; +import dan200.computercraft.api.redstone.BundledRedstoneProvider; +import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.TurtleRefuelHandler; import dan200.computercraft.impl.ComputerCraftAPIService; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nullable; @@ -51,16 +46,16 @@ public static String getInstalledVersion() { *

* Use in conjunction with createSaveDirMount() to create a unique place for your peripherals or media items to store files. * - * @param world The world for which the save dir should be created. This should be the server side world object. + * @param server The server for which the save dir should be created. * @param parentSubPath The folder path within the save directory where the new directory should be created. eg: "computercraft/disk" * @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason. *

* eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now * available for writing. - * @see #createSaveDirMount(Level, String, long) + * @see #createSaveDirMount(MinecraftServer, String, long) */ - public static int createUniqueNumberedSaveDir(Level world, String parentSubPath) { - return getInstance().createUniqueNumberedSaveDir(world, parentSubPath); + public static int createUniqueNumberedSaveDir(MinecraftServer server, String parentSubPath) { + return getInstance().createUniqueNumberedSaveDir(server, parentSubPath); } /** @@ -69,21 +64,21 @@ public static int createUniqueNumberedSaveDir(Level world, String parentSubPath) * Use in conjunction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the * users save directory onto a computers file system. * - * @param world The world for which the save dir can be found. This should be the server side world object. + * @param server The server which the save dir can be found. * @param subPath The folder path within the save directory that the mount should map to. eg: "computer/disk/42". * Use createUniqueNumberedSaveDir() to create a new numbered folder to use. * @param capacity The amount of data that can be stored in the directory before it fills up, in bytes. * @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() * to mount this on a Computers' file system. - * @see #createUniqueNumberedSaveDir(Level, String) - * @see IComputerAccess#mount(String, IMount) - * @see IComputerAccess#mountWritable(String, IWritableMount) - * @see IMount - * @see IWritableMount + * @see #createUniqueNumberedSaveDir(MinecraftServer, String) + * @see IComputerAccess#mount(String, Mount) + * @see IComputerAccess#mountWritable(String, WritableMount) + * @see Mount + * @see WritableMount */ @Nullable - public static IWritableMount createSaveDirMount(Level world, String subPath, long capacity) { - return getInstance().createSaveDirMount(world, subPath, capacity); + public static WritableMount createSaveDirMount(MinecraftServer server, String subPath, long capacity) { + return getInstance().createSaveDirMount(server, subPath, capacity); } /** @@ -97,29 +92,17 @@ public static IWritableMount createSaveDirMount(Level world, String subPath, lon * "/data/computercraft/lua/rom". We construct a mount for that with * {@code createResourceMount("computercraft", "lua/rom")}. * + * @param server The current Minecraft server, from which to read resources from. * @param domain The domain under which to look for resources. eg: "mymod". * @param subPath The subPath under which to look for resources. eg: "lua/myfiles". * @return The mount, or {@code null} if it could be created for some reason. - * @see IComputerAccess#mount(String, IMount) - * @see IComputerAccess#mountWritable(String, IWritableMount) - * @see IMount + * @see IComputerAccess#mount(String, Mount) + * @see IComputerAccess#mountWritable(String, WritableMount) + * @see Mount */ @Nullable - public static IMount createResourceMount(String domain, String subPath) { - return getInstance().createResourceMount(domain, subPath); - } - - /** - * Registers a peripheral provider to convert blocks into {@link IPeripheral} implementations. - * - * @param provider The peripheral provider to register. - * @see IPeripheral - * @see IPeripheralProvider - * @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)} instead. - */ - @Deprecated(forRemoval = true) - public static void registerPeripheralProvider(IPeripheralProvider provider) { - getInstance().registerPeripheralProvider(provider); + public static Mount createResourceMount(MinecraftServer server, String domain, String subPath) { + return getInstance().createResourceMount(server, domain, subPath); } /** @@ -132,25 +115,13 @@ public static void registerGenericSource(GenericSource source) { getInstance().registerGenericSource(source); } - /** - * Registers a capability that can be used by generic peripherals. - * - * @param capability The capability to register. - * @see GenericSource - * @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI} instead. - */ - @Deprecated(forRemoval = true) - public static void registerGenericCapability(Capability capability) { - getInstance().registerGenericCapability(capability); - } - /** * Registers a bundled redstone provider to provide bundled redstone output for blocks. * * @param provider The bundled redstone provider to register. - * @see IBundledRedstoneProvider + * @see BundledRedstoneProvider */ - public static void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) { + public static void registerBundledRedstoneProvider(BundledRedstoneProvider provider) { getInstance().registerBundledRedstoneProvider(provider); } @@ -162,7 +133,7 @@ public static void registerBundledRedstoneProvider(IBundledRedstoneProvider prov * @param side The side to extract the bundled redstone output from. * @return If there is a block capable of emitting bundled redstone at the location, it's signal (0-65535) will be returned. * If there is no block capable of emitting bundled redstone at the location, -1 will be returned. - * @see IBundledRedstoneProvider + * @see BundledRedstoneProvider */ public static int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side) { return getInstance().getBundledRedstoneOutput(world, pos, side); @@ -172,38 +143,33 @@ public static int getBundledRedstoneOutput(Level world, BlockPos pos, Direction * Registers a media provider to provide {@link IMedia} implementations for Items. * * @param provider The media provider to register. - * @see IMediaProvider + * @see MediaProvider */ - public static void registerMediaProvider(IMediaProvider provider) { + public static void registerMediaProvider(MediaProvider provider) { getInstance().registerMediaProvider(provider); } /** * Attempt to get the game-wide wireless network. * + * @param server The current Minecraft server. * @return The global wireless network, or {@code null} if it could not be fetched. */ - public static IPacketNetwork getWirelessNetwork() { - return getInstance().getWirelessNetwork(); - } - - public static void registerAPIFactory(ILuaAPIFactory factory) { - getInstance().registerAPIFactory(factory); + public static PacketNetwork getWirelessNetwork(MinecraftServer server) { + return getInstance().getWirelessNetwork(server); } /** - * Registers a detail provider to provide additional details for blocks, fluids and items when inspected by methods - * such as {@code turtle.getItemDetail()} or {@code turtle.inspect()}. + * Register a custom {@link ILuaAPI}, which may be added onto all computers without requiring a peripheral. + *

+ * Before implementing this interface, consider alternative methods of providing methods. It is generally preferred + * to use peripherals to provide functionality to users. * - * @param type The type of object that this provider can provide details for. Should be {@link BlockReference}, - * {@code net.minecraftforge.fluids.FluidStack} or {@link ItemStack}. - * @param provider The detail provider to register. - * @param The type of object that this provider can provide details for. - * @deprecated Use {@link DetailRegistry#addProvider(IDetailProvider)} to register your provider. + * @param factory The factory for your API subclass. + * @see ILuaAPIFactory */ - @Deprecated(forRemoval = true) - public static void registerDetailProvider(Class type, IDetailProvider provider) { - getInstance().registerDetailProvider(type, provider); + public static void registerAPIFactory(ILuaAPIFactory factory) { + getInstance().registerAPIFactory(factory); } /** @@ -211,27 +177,19 @@ public static void registerDetailProvider(Class type, IDetailProvider * * @param element The element to construct it for * @return The element's node - * @see IWiredElement#getNode() + * @see WiredElement#getNode() */ - public static IWiredNode createWiredNodeForElement(IWiredElement element) { + public static WiredNode createWiredNodeForElement(WiredElement element) { return getInstance().createWiredNodeForElement(element); } /** - * Get the wired network element for a block in world. + * Register a refuel handler for turtles. This may be used to provide alternative fuel sources, such as consuming RF + * batteries. * - * @param world The world the block exists in - * @param pos The position the block exists in - * @param side The side to extract the network element from - * @return The element's node - * @see IWiredElement#getNode() - * @deprecated Use {@code dan200.computercraft.api.ForgeComputerCraftAPI#getWiredElementAt(BlockGetter, BlockPos, Direction)} + * @param handler The turtle refuel handler. + * @see TurtleRefuelHandler#refuel(ITurtleAccess, ItemStack, int, int) */ - @Deprecated(forRemoval = true) - public static LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { - return getInstance().getWiredElementAt(world, pos, side); - } - public static void registerRefuelHandler(TurtleRefuelHandler handler) { getInstance().registerRefuelHandler(handler); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/detail/BasicItemDetailProvider.java b/projects/common-api/src/main/java/dan200/computercraft/api/detail/BasicItemDetailProvider.java index 8d0e16088..a83a61768 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/detail/BasicItemDetailProvider.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/detail/BasicItemDetailProvider.java @@ -18,7 +18,7 @@ * * @param The type the stack's item must have. */ -public abstract class BasicItemDetailProvider implements IDetailProvider { +public abstract class BasicItemDetailProvider implements DetailProvider { private final Class itemType; private final @Nullable String namespace; diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/detail/IDetailProvider.java b/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailProvider.java similarity index 97% rename from projects/common-api/src/main/java/dan200/computercraft/api/detail/IDetailProvider.java rename to projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailProvider.java index 3692b75a0..df35f377c 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/detail/IDetailProvider.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailProvider.java @@ -17,7 +17,7 @@ * @see DetailRegistry */ @FunctionalInterface -public interface IDetailProvider { +public interface DetailProvider { /** * Provide additional details for the given object. This method is called by functions such as * {@code turtle.getItemDetail()} and {@code turtle.inspect()}. New properties should be added to the given diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailRegistry.java b/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailRegistry.java index 119533962..2cd1cc041 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailRegistry.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/detail/DetailRegistry.java @@ -25,9 +25,9 @@ public interface DetailRegistry { * Registers a detail provider. * * @param provider The detail provider to register. - * @see IDetailProvider + * @see DetailProvider */ - void addProvider(IDetailProvider provider); + void addProvider(DetailProvider provider); /** * Compute basic details about an object. This is cheaper than computing all details operation, and so is suitable diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java b/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java index 178d7641c..8340ae978 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/media/IMedia.java @@ -5,11 +5,14 @@ */ package dan200.computercraft.api.media; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.ComputerCraftAPI; +import dan200.computercraft.api.filesystem.Mount; +import dan200.computercraft.api.filesystem.WritableMount; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; import javax.annotation.Nullable; @@ -17,7 +20,7 @@ * Represents an item that can be placed in a disk drive and used by a Computer. *

* Implement this interface on your {@link Item} class to allow it to be used in the drive. Alternatively, register - * a {@link IMediaProvider}. + * a {@link MediaProvider}. */ public interface IMedia { /** @@ -68,16 +71,16 @@ default SoundEvent getAudio(ItemStack stack) { * be mounted onto the filesystem of the computer while the media is in the disk drive. * * @param stack The {@link ItemStack} to modify. - * @param world The world in which the item and disk drive reside. + * @param level The world in which the item and disk drive reside. * @return The mount, or null if this item does not represent an item with data. If the mount returned also - * implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable() - * @see IMount - * @see dan200.computercraft.api.filesystem.IWritableMount - * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(Level, String, long) - * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(String, String) + * implements {@link WritableMount}, it will mounted using mountWritable() + * @see Mount + * @see WritableMount + * @see ComputerCraftAPI#createSaveDirMount(MinecraftServer, String, long) + * @see ComputerCraftAPI#createResourceMount(MinecraftServer, String, String) */ @Nullable - default IMount createDataMount(ItemStack stack, Level world) { + default Mount createDataMount(ItemStack stack, ServerLevel level) { return null; } } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMediaProvider.java b/projects/common-api/src/main/java/dan200/computercraft/api/media/MediaProvider.java similarity index 91% rename from projects/common-api/src/main/java/dan200/computercraft/api/media/IMediaProvider.java rename to projects/common-api/src/main/java/dan200/computercraft/api/media/MediaProvider.java index a9bfea454..bb416b04e 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/media/IMediaProvider.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/media/MediaProvider.java @@ -12,16 +12,16 @@ /** * This interface is used to provide {@link IMedia} implementations for {@link ItemStack}. * - * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider) + * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(MediaProvider) */ @FunctionalInterface -public interface IMediaProvider { +public interface MediaProvider { /** * Produce an IMedia implementation from an ItemStack. * * @param stack The stack from which to extract the media information. * @return An {@link IMedia} implementation, or {@code null} if the item is not something you wish to handle - * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider) + * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(MediaProvider) */ @Nullable IMedia getMedia(ItemStack stack); diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/Packet.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/Packet.java index edf5d9ccd..4c2588c6b 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/Packet.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/Packet.java @@ -6,7 +6,7 @@ package dan200.computercraft.api.network; /** - * Represents a packet which may be sent across a {@link IPacketNetwork}. + * Represents a packet which may be sent across a {@link PacketNetwork}. * * @param channel The channel to send the packet along. Receiving devices should only process packets from on * channels they are listening to. @@ -14,16 +14,16 @@ * @param payload The contents of this packet. This should be a "valid" Lua object, safe for queuing as an * event or returning from a peripheral call. * @param sender The object which sent this packet. - * @see IPacketSender - * @see IPacketNetwork#transmitSameDimension(Packet, double) - * @see IPacketNetwork#transmitInterdimensional(Packet) - * @see IPacketReceiver#receiveDifferentDimension(Packet) - * @see IPacketReceiver#receiveSameDimension(Packet, double) + * @see PacketSender + * @see PacketNetwork#transmitSameDimension(Packet, double) + * @see PacketNetwork#transmitInterdimensional(Packet) + * @see PacketReceiver#receiveDifferentDimension(Packet) + * @see PacketReceiver#receiveSameDimension(Packet, double) */ public record Packet( int channel, int replyChannel, Object payload, - IPacketSender sender + PacketSender sender ) { } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketNetwork.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketNetwork.java similarity index 85% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketNetwork.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/PacketNetwork.java index 48392083b..c1ea246c6 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketNetwork.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketNetwork.java @@ -10,22 +10,22 @@ * A packet network represents a collection of devices which can send and receive packets. * * @see Packet - * @see IPacketReceiver + * @see PacketReceiver */ -public interface IPacketNetwork { +public interface PacketNetwork { /** * Add a receiver to the network. * * @param receiver The receiver to register to the network. */ - void addReceiver(IPacketReceiver receiver); + void addReceiver(PacketReceiver receiver); /** * Remove a receiver from the network. * * @param receiver The device to remove from the network. */ - void removeReceiver(IPacketReceiver receiver); + void removeReceiver(PacketReceiver receiver); /** * Determine whether this network is wireless. @@ -41,7 +41,7 @@ public interface IPacketNetwork { * @param packet The packet to send. * @param range The maximum distance this packet will be sent. * @see #transmitInterdimensional(Packet) - * @see IPacketReceiver#receiveSameDimension(Packet, double) + * @see PacketReceiver#receiveSameDimension(Packet, double) */ void transmitSameDimension(Packet packet, double range); @@ -51,7 +51,7 @@ public interface IPacketNetwork { * * @param packet The packet to send. * @see #transmitSameDimension(Packet, double) - * @see IPacketReceiver#receiveDifferentDimension(Packet) + * @see PacketReceiver#receiveDifferentDimension(Packet) */ void transmitInterdimensional(Packet packet); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketReceiver.java similarity index 84% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/PacketReceiver.java index 7c860aca9..a8cea9ef8 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketReceiver.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketReceiver.java @@ -10,9 +10,9 @@ /** - * An object on an {@link IPacketNetwork}, capable of receiving packets. + * An object on an {@link PacketNetwork}, capable of receiving packets. */ -public interface IPacketReceiver { +public interface PacketReceiver { /** * Get the world in which this packet receiver exists. * @@ -37,7 +37,7 @@ public interface IPacketReceiver { * @return The maximum distance this device can send and receive messages. * @see #isInterdimensional() * @see #receiveSameDimension(Packet packet, double) - * @see IPacketNetwork#transmitInterdimensional(Packet) + * @see PacketNetwork#transmitInterdimensional(Packet) */ double getRange(); @@ -49,7 +49,7 @@ public interface IPacketReceiver { * @return Whether this receiver receives packets from other dimensions. * @see #getRange() * @see #receiveDifferentDimension(Packet) - * @see IPacketNetwork#transmitInterdimensional(Packet) + * @see PacketNetwork#transmitInterdimensional(Packet) */ boolean isInterdimensional(); @@ -61,8 +61,8 @@ public interface IPacketReceiver { * @param distance The distance this packet has travelled from the source. * @see Packet * @see #getRange() - * @see IPacketNetwork#transmitSameDimension(Packet, double) - * @see IPacketNetwork#transmitInterdimensional(Packet) + * @see PacketNetwork#transmitSameDimension(Packet, double) + * @see PacketNetwork#transmitInterdimensional(Packet) */ void receiveSameDimension(Packet packet, double distance); @@ -72,8 +72,8 @@ public interface IPacketReceiver { * @param packet The packet to receive. Generally you should check that you are listening on the given channel and, * if so, queue the appropriate modem event. * @see Packet - * @see IPacketNetwork#transmitInterdimensional(Packet) - * @see IPacketNetwork#transmitSameDimension(Packet, double) + * @see PacketNetwork#transmitInterdimensional(Packet) + * @see PacketNetwork#transmitSameDimension(Packet, double) * @see #isInterdimensional() */ void receiveDifferentDimension(Packet packet); diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketSender.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketSender.java similarity index 90% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketSender.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/PacketSender.java index 6dcfdf03f..a1aa74a3a 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/IPacketSender.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/PacketSender.java @@ -10,9 +10,9 @@ /** - * An object on a {@link IPacketNetwork}, capable of sending packets. + * An object on a {@link PacketNetwork}, capable of sending packets. */ -public interface IPacketSender { +public interface PacketSender { /** * Get the world in which this packet sender exists. * diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredElement.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredElement.java similarity index 78% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredElement.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredElement.java index 660d63c7c..c2a78a684 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredElement.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredElement.java @@ -11,21 +11,21 @@ /** * An object which may be part of a wired network. *

- * Elements should construct a node using {@link ComputerCraftAPI#createWiredNodeForElement(IWiredElement)}. This acts + * Elements should construct a node using {@link ComputerCraftAPI#createWiredNodeForElement(WiredElement)}. This acts * as a proxy for all network objects. Whilst the node may change networks, an element's node should remain constant * for its lifespan. *

* Elements are generally tied to a block or tile entity in world. In such as case, one should provide the - * {@link IWiredElement} capability for the appropriate sides. + * {@link WiredElement} capability for the appropriate sides. */ -public interface IWiredElement extends IWiredSender { +public interface WiredElement extends WiredSender { /** * Called when objects on the network change. This may occur when network nodes are added or removed, or when * peripherals change. * * @param change The change which occurred. - * @see IWiredNetworkChange + * @see WiredNetworkChange */ - default void networkChanged(IWiredNetworkChange change) { + default void networkChanged(WiredNetworkChange change) { } } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetwork.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetwork.java similarity index 78% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetwork.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetwork.java index 5fb1387b6..42c797cf7 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetwork.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetwork.java @@ -10,20 +10,20 @@ import java.util.Map; /** - * A wired network is composed of one of more {@link IWiredNode}s, a set of connections between them, and a series + * A wired network is composed of one of more {@link WiredNode}s, a set of connections between them, and a series * of peripherals. *

* Networks from a connected graph. This means there is some path between all nodes on the network. Further more, if - * there is some path between two nodes then they must be on the same network. {@link IWiredNetwork} will automatically + * there is some path between two nodes then they must be on the same network. {@link WiredNetwork} will automatically * handle the merging and splitting of networks (and thus changing of available nodes and peripherals) as connections * change. *

* This does mean one can not rely on the network remaining consistent between subsequent operations. Consequently, - * it is generally preferred to use the methods provided by {@link IWiredNode}. + * it is generally preferred to use the methods provided by {@link WiredNode}. * - * @see IWiredNode#getNetwork() + * @see WiredNode#getNetwork() */ -public interface IWiredNetwork { +public interface WiredNetwork { /** * Create a connection between two nodes. *

@@ -34,10 +34,10 @@ public interface IWiredNetwork { * @return {@code true} if a connection was created or {@code false} if the connection already exists. * @throws IllegalStateException If neither node is on the network. * @throws IllegalArgumentException If {@code left} and {@code right} are equal. - * @see IWiredNode#connectTo(IWiredNode) - * @see IWiredNetwork#connect(IWiredNode, IWiredNode) + * @see WiredNode#connectTo(WiredNode) + * @see WiredNetwork#connect(WiredNode, WiredNode) */ - boolean connect(IWiredNode left, IWiredNode right); + boolean connect(WiredNode left, WiredNode right); /** * Destroy a connection between this node and another. @@ -49,10 +49,10 @@ public interface IWiredNetwork { * @return {@code true} if a connection was destroyed or {@code false} if no connection exists. * @throws IllegalArgumentException If either node is not on the network. * @throws IllegalArgumentException If {@code left} and {@code right} are equal. - * @see IWiredNode#disconnectFrom(IWiredNode) - * @see IWiredNetwork#connect(IWiredNode, IWiredNode) + * @see WiredNode#disconnectFrom(WiredNode) + * @see WiredNetwork#connect(WiredNode, WiredNode) */ - boolean disconnect(IWiredNode left, IWiredNode right); + boolean disconnect(WiredNode left, WiredNode right); /** * Sever all connections this node has, removing it from this network. @@ -64,9 +64,9 @@ public interface IWiredNetwork { * @return Whether this node was removed from the network. One cannot remove a node from a network where it is the * only element. * @throws IllegalArgumentException If the node is not in the network. - * @see IWiredNode#remove() + * @see WiredNode#remove() */ - boolean remove(IWiredNode node); + boolean remove(WiredNode node); /** * Update the peripherals a node provides. @@ -77,7 +77,7 @@ public interface IWiredNetwork { * @param node The node to attach peripherals for. * @param peripherals The new peripherals for this node. * @throws IllegalArgumentException If the node is not in the network. - * @see IWiredNode#updatePeripherals(Map) + * @see WiredNode#updatePeripherals(Map) */ - void updatePeripherals(IWiredNode node, Map peripherals); + void updatePeripherals(WiredNode node, Map peripherals); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetworkChange.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetworkChange.java similarity index 91% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetworkChange.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetworkChange.java index 5f87f0e9c..2f2494f54 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNetworkChange.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNetworkChange.java @@ -12,9 +12,9 @@ /** * Represents a change to the objects on a wired network. * - * @see IWiredElement#networkChanged(IWiredNetworkChange) + * @see WiredElement#networkChanged(WiredNetworkChange) */ -public interface IWiredNetworkChange { +public interface WiredNetworkChange { /** * A set of peripherals which have been removed. Note that there may be entries with the same name * in the added and removed set, but with a different peripheral. diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNode.java similarity index 82% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNode.java index bfe14cb0e..747c0542f 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredNode.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredNode.java @@ -5,13 +5,13 @@ */ package dan200.computercraft.api.network.wired; -import dan200.computercraft.api.network.IPacketNetwork; +import dan200.computercraft.api.network.PacketNetwork; import dan200.computercraft.api.peripheral.IPeripheral; import java.util.Map; /** - * Wired nodes act as a layer between {@link IWiredElement}s and {@link IWiredNetwork}s. + * Wired nodes act as a layer between {@link WiredElement}s and {@link WiredNetwork}s. *

* Firstly, a node acts as a packet network, capable of sending and receiving modem messages to connected nodes. These * methods may be safely used on any thread. @@ -23,13 +23,13 @@ * Wired nodes also provide several convenience methods for interacting with a wired network. These should only ever * be used on the main server thread. */ -public interface IWiredNode extends IPacketNetwork { +public interface WiredNode extends PacketNetwork { /** * The associated element for this network node. * * @return This node's element. */ - IWiredElement getElement(); + WiredElement getElement(); /** * The network this node is currently connected to. Note that this may change @@ -39,7 +39,7 @@ public interface IWiredNode extends IPacketNetwork { * * @return This node's network. */ - IWiredNetwork getNetwork(); + WiredNetwork getNetwork(); /** * Create a connection from this node to another. @@ -48,10 +48,10 @@ public interface IWiredNode extends IPacketNetwork { * * @param node The other node to connect to. * @return {@code true} if a connection was created or {@code false} if the connection already exists. - * @see IWiredNetwork#connect(IWiredNode, IWiredNode) - * @see IWiredNode#disconnectFrom(IWiredNode) + * @see WiredNetwork#connect(WiredNode, WiredNode) + * @see WiredNode#disconnectFrom(WiredNode) */ - default boolean connectTo(IWiredNode node) { + default boolean connectTo(WiredNode node) { return getNetwork().connect(this, node); } @@ -63,10 +63,10 @@ default boolean connectTo(IWiredNode node) { * @param node The other node to disconnect from. * @return {@code true} if a connection was destroyed or {@code false} if no connection exists. * @throws IllegalArgumentException If {@code node} is not on the same network. - * @see IWiredNetwork#disconnect(IWiredNode, IWiredNode) - * @see IWiredNode#connectTo(IWiredNode) + * @see WiredNetwork#disconnect(WiredNode, WiredNode) + * @see WiredNode#connectTo(WiredNode) */ - default boolean disconnectFrom(IWiredNode node) { + default boolean disconnectFrom(WiredNode node) { return getNetwork().disconnect(this, node); } @@ -79,7 +79,7 @@ default boolean disconnectFrom(IWiredNode node) { * @return Whether this node was removed from the network. One cannot remove a node from a network where it is the * only element. * @throws IllegalArgumentException If the node is not in the network. - * @see IWiredNetwork#remove(IWiredNode) + * @see WiredNetwork#remove(WiredNode) */ default boolean remove() { return getNetwork().remove(this); @@ -92,7 +92,7 @@ default boolean remove() { * that your network element owns. * * @param peripherals The new peripherals for this node. - * @see IWiredNetwork#updatePeripherals(IWiredNode, Map) + * @see WiredNetwork#updatePeripherals(WiredNode, Map) */ default void updatePeripherals(Map peripherals) { getNetwork().updatePeripherals(this, peripherals); diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredSender.java b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredSender.java similarity index 67% rename from projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredSender.java rename to projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredSender.java index a89404490..652181beb 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/IWiredSender.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/network/wired/WiredSender.java @@ -5,16 +5,16 @@ */ package dan200.computercraft.api.network.wired; -import dan200.computercraft.api.network.IPacketSender; +import dan200.computercraft.api.network.PacketSender; /** - * An object on a {@link IWiredNetwork} capable of sending packets. + * An object on a {@link WiredNetwork} capable of sending packets. *

- * Unlike a regular {@link IPacketSender}, this must be associated with the node you are attempting to + * Unlike a regular {@link PacketSender}, this must be associated with the node you are attempting to * to send the packet from. */ -public interface IWiredSender extends IPacketSender { +public interface WiredSender extends PacketSender { /** * The node in the network representing this object. *

@@ -23,5 +23,5 @@ public interface IWiredSender extends IPacketSender { * * @return The node for this element. */ - IWiredNode getNode(); + WiredNode getNode(); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java index 3ad220978..891e63346 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/AbstractPocketUpgrade.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.api.pocket; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -27,7 +27,7 @@ protected AbstractPocketUpgrade(ResourceLocation id, String adjective, ItemStack } protected AbstractPocketUpgrade(ResourceLocation id, ItemStack stack) { - this(id, IUpgradeBase.getDefaultAdjective(id), stack); + this(id, UpgradeBase.getDefaultAdjective(id), stack); } @Override diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java index e917c6c50..6abfd56db 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/IPocketUpgrade.java @@ -6,7 +6,7 @@ package dan200.computercraft.api.pocket; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import net.minecraft.world.level.Level; import javax.annotation.Nullable; @@ -23,7 +23,7 @@ * * @see PocketUpgradeSerialiser For how to register a pocket computer upgrade. */ -public interface IPocketUpgrade extends IUpgradeBase { +public interface IPocketUpgrade extends UpgradeBase { /** * Creates a peripheral for the pocket computer. *

diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/PocketUpgradeSerialiser.java b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/PocketUpgradeSerialiser.java index b394b6d03..01b30ce39 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/pocket/PocketUpgradeSerialiser.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/pocket/PocketUpgradeSerialiser.java @@ -6,7 +6,7 @@ package dan200.computercraft.api.pocket; 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.impl.upgrades.SerialiserWithCraftingItem; import dan200.computercraft.impl.upgrades.SimpleSerialiser; @@ -15,8 +15,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.SimpleRecipeSerializer; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.RegistryManager; import java.util.function.BiFunction; import java.util.function.Function; @@ -37,18 +35,6 @@ public interface PocketUpgradeSerialiser extends Upgra */ ResourceKey>> REGISTRY_ID = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "pocket_upgrade_serialiser")); - /** - * The associated registry. - * - * @return The registry for pocket upgrade serialisers. - * @see #REGISTRY_ID - * @deprecated Use {@link #REGISTRY_ID} directly. - */ - @Deprecated(forRemoval = true) - static IForgeRegistry> registry() { - return RegistryManager.ACTIVE.getRegistry(REGISTRY_ID); - } - /** * Create an upgrade serialiser for a simple upgrade. This is similar to a {@link SimpleRecipeSerializer}, but for * upgrades. @@ -73,7 +59,7 @@ private Impl(Function constructor) { * Create an upgrade serialiser for a simple upgrade whose crafting item can be specified. * * @param factory Generate a new upgrade with a specific ID and crafting item. The returned upgrade's - * {@link IUpgradeBase#getCraftingItem()} MUST equal the provided item. + * {@link UpgradeBase#getCraftingItem()} MUST equal the provided item. * @param The type of the generated upgrade. * @return The serialiser for this upgrade. * @see #simple(Function) For upgrades whose crafting stack should not vary. diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/redstone/IBundledRedstoneProvider.java b/projects/common-api/src/main/java/dan200/computercraft/api/redstone/BundledRedstoneProvider.java similarity index 79% rename from projects/common-api/src/main/java/dan200/computercraft/api/redstone/IBundledRedstoneProvider.java rename to projects/common-api/src/main/java/dan200/computercraft/api/redstone/BundledRedstoneProvider.java index 7665c128d..7f7353ba5 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/redstone/IBundledRedstoneProvider.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/redstone/BundledRedstoneProvider.java @@ -5,18 +5,18 @@ */ package dan200.computercraft.api.redstone; +import dan200.computercraft.api.ComputerCraftAPI; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.level.Level; - /** * This interface is used to provide bundled redstone output for blocks. * - * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider) + * @see ComputerCraftAPI#registerBundledRedstoneProvider(BundledRedstoneProvider) */ @FunctionalInterface -public interface IBundledRedstoneProvider { +public interface BundledRedstoneProvider { /** * Produce an bundled redstone output from a block location. * @@ -25,7 +25,7 @@ public interface IBundledRedstoneProvider { * @param side The side to extract the bundled redstone output from. * @return A number in the range 0-65535 to indicate this block is providing output, or -1 if you do not wish to * handle this block. - * @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider) + * @see ComputerCraftAPI#registerBundledRedstoneProvider(BundledRedstoneProvider) */ int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java index 4f1f53a83..955f2da3b 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/AbstractTurtleUpgrade.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.api.turtle; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -29,7 +29,7 @@ protected AbstractTurtleUpgrade(ResourceLocation id, TurtleUpgradeType type, Str } protected AbstractTurtleUpgrade(ResourceLocation id, TurtleUpgradeType type, ItemStack stack) { - this(id, type, IUpgradeBase.getDefaultAdjective(id), stack); + this(id, type, UpgradeBase.getDefaultAdjective(id), stack); } @Override diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java index 3652428fc..9921ebfe1 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java @@ -15,7 +15,6 @@ import net.minecraft.world.Container; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.items.IItemHandlerModifiable; import javax.annotation.Nullable; @@ -43,7 +42,7 @@ public interface ITurtleAccess { /** * Determine if this turtle has been removed. *

- * It's possible for a turtle to be removed while a {@link ITurtleCommand} is executed, for instance if interacting + * It's possible for a turtle to be removed while a {@link TurtleCommand} is executed, for instance if interacting * with a block causes the turtle to be blown up. It's recommended you check the turtle is still present before * trying to interact with it again. *

@@ -156,23 +155,9 @@ public interface ITurtleAccess { * Note: this inventory should only be accessed and modified on the server thread. * * @return This turtle's inventory - * @see #getItemHandler() */ Container getInventory(); - /** - * Get the inventory of this turtle as an {@link IItemHandlerModifiable}. - *

- * Note: this inventory should only be accessed and modified on the server thread. - * - * @return This turtle's inventory - * @see #getInventory() - * @see IItemHandlerModifiable - * @deprecated Use {@link #getInventory()} directly. - */ - @Deprecated(forRemoval = true) - IItemHandlerModifiable getItemHandler(); - /** * Determine whether this turtle will require fuel when performing actions. * @@ -239,10 +224,10 @@ public interface ITurtleAccess { * @return The objects the command returned when executed. you should probably return these to the player * unchanged if called from a peripheral method. * @throws UnsupportedOperationException When attempting to execute a command on the client side. - * @see ITurtleCommand + * @see TurtleCommand * @see MethodResult#pullEvent(String, ILuaCallback) */ - MethodResult executeCommand(ITurtleCommand command); + MethodResult executeCommand(TurtleCommand command); /** * Start playing a specific animation. This will prevent other turtle commands from executing until diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java index 7a34ef0c4..ad3392887 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleUpgrade.java @@ -6,7 +6,7 @@ package dan200.computercraft.api.turtle; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import net.minecraft.core.Direction; import javax.annotation.Nullable; @@ -24,7 +24,7 @@ * * @see TurtleUpgradeSerialiser For how to register a turtle upgrade. */ -public interface ITurtleUpgrade extends IUpgradeBase { +public interface ITurtleUpgrade extends UpgradeBase { /** * Return whether this turtle adds a tool or a peripheral to the turtle. * diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleCommand.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommand.java similarity index 83% rename from projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleCommand.java rename to projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommand.java index fdd90cf28..50ab74f85 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/ITurtleCommand.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommand.java @@ -7,12 +7,12 @@ /** - * An interface for objects executing custom turtle commands, used with {@link ITurtleAccess#executeCommand(ITurtleCommand)}. + * An interface for objects executing custom turtle commands, used with {@link ITurtleAccess#executeCommand(TurtleCommand)}. * - * @see ITurtleAccess#executeCommand(ITurtleCommand) + * @see ITurtleAccess#executeCommand(TurtleCommand) */ @FunctionalInterface -public interface ITurtleCommand { +public interface TurtleCommand { /** * Will be called by the turtle on the main thread when it is time to execute the custom command. *

@@ -21,7 +21,7 @@ public interface ITurtleCommand { * * @param turtle Access to the turtle for whom the command was issued. * @return A result, indicating whether this action succeeded or not. - * @see ITurtleAccess#executeCommand(ITurtleCommand) + * @see ITurtleAccess#executeCommand(TurtleCommand) * @see TurtleCommandResult#success() * @see TurtleCommandResult#failure(String) * @see TurtleCommandResult diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java index a029ce8ca..9cc342471 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleCommandResult.java @@ -12,7 +12,7 @@ /** * Used to indicate the result of executing a turtle command. * - * @see ITurtleCommand#execute(ITurtleAccess) + * @see TurtleCommand#execute(ITurtleAccess) * @see ITurtleUpgrade#useTool(ITurtleAccess, TurtleSide, TurtleVerb, Direction) */ public final class TurtleCommandResult { diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleUpgradeSerialiser.java b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleUpgradeSerialiser.java index ff36481fa..a6f4a24d7 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleUpgradeSerialiser.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/turtle/TurtleUpgradeSerialiser.java @@ -6,7 +6,7 @@ package dan200.computercraft.api.turtle; 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.impl.upgrades.SerialiserWithCraftingItem; import dan200.computercraft.impl.upgrades.SimpleSerialiser; @@ -16,8 +16,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.SimpleRecipeSerializer; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.RegistryManager; import java.util.function.BiFunction; import java.util.function.Function; @@ -72,18 +70,6 @@ public interface TurtleUpgradeSerialiser extends Upgra */ ResourceKey>> REGISTRY_ID = ResourceKey.createRegistryKey(new ResourceLocation(ComputerCraftAPI.MOD_ID, "turtle_upgrade_serialiser")); - /** - * The associated registry. - * - * @return The registry for pocket upgrade serialisers. - * @see #REGISTRY_ID - * @deprecated Use {@link #REGISTRY_ID} directly. - */ - @Deprecated(forRemoval = true) - static IForgeRegistry> registry() { - return RegistryManager.ACTIVE.getRegistry(REGISTRY_ID); - } - /** * Create an upgrade serialiser for a simple upgrade. This is similar to a {@link SimpleRecipeSerializer}, but for * upgrades. @@ -108,7 +94,7 @@ private Impl(Function constructor) { * Create an upgrade serialiser for a simple upgrade whose crafting item can be specified. * * @param factory Generate a new upgrade with a specific ID and crafting item. The returned upgrade's - * {@link IUpgradeBase#getCraftingItem()} MUST equal the provided item. + * {@link UpgradeBase#getCraftingItem()} MUST equal the provided item. * @param The type of the generated upgrade. * @return The serialiser for this upgrade. * @see #simple(Function) For upgrades whose crafting stack should not vary. diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/IUpgradeBase.java b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeBase.java similarity index 99% rename from projects/common-api/src/main/java/dan200/computercraft/api/upgrades/IUpgradeBase.java rename to projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeBase.java index 81e17ad1b..b270c03c7 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/IUpgradeBase.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeBase.java @@ -17,7 +17,7 @@ /** * Common functionality between {@link ITurtleUpgrade} and {@link IPocketUpgrade}. */ -public interface IUpgradeBase { +public interface UpgradeBase { /** * Gets a unique identifier representing this type of turtle upgrade. eg: "computercraft:wireless_modem" * or "my_mod:my_upgrade". diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeDataProvider.java b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeDataProvider.java index 33e8ff100..703eea5c8 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeDataProvider.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeDataProvider.java @@ -37,7 +37,7 @@ * @param The base class of upgrades. * @param The upgrade serialiser to register for. */ -public abstract class UpgradeDataProvider> implements DataProvider { +public abstract class UpgradeDataProvider> implements DataProvider { private static final Logger LOGGER = LogManager.getLogger(); private final DataGenerator generator; diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeSerialiser.java b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeSerialiser.java index 37fd38006..79d0b4fbc 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeSerialiser.java +++ b/projects/common-api/src/main/java/dan200/computercraft/api/upgrades/UpgradeSerialiser.java @@ -22,13 +22,13 @@ * @see TurtleUpgradeSerialiser * @see PocketUpgradeSerialiser */ -public interface UpgradeSerialiser { +public interface UpgradeSerialiser { /** * Read this upgrade from a JSON file in a datapack. * * @param id The ID of this upgrade. * @param object The JSON object to load this upgrade from. - * @return The constructed upgrade, with a {@link IUpgradeBase#getUpgradeID()} equal to {@code id}. + * @return The constructed upgrade, with a {@link UpgradeBase#getUpgradeID()} equal to {@code id}. * @see net.minecraft.util.GsonHelper For additional JSON helper methods. */ T fromJson(ResourceLocation id, JsonObject object); @@ -38,7 +38,7 @@ public interface UpgradeSerialiser { * * @param id The ID of this upgrade. * @param buffer The buffer object to read this upgrade from. - * @return The constructed upgrade, with a {@link IUpgradeBase#getUpgradeID()} equal to {@code id}. + * @return The constructed upgrade, with a {@link UpgradeBase#getUpgradeID()} equal to {@code id}. */ T fromNetwork(ResourceLocation id, FriendlyByteBuf buffer); diff --git a/projects/common-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIService.java b/projects/common-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIService.java index a5d80744c..73a3dfd0d 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIService.java +++ b/projects/common-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIService.java @@ -8,25 +8,21 @@ import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.detail.BlockReference; import dan200.computercraft.api.detail.DetailRegistry; -import dan200.computercraft.api.detail.IDetailProvider; -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.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.peripheral.IPeripheralProvider; -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 net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.util.LazyOptional; import org.jetbrains.annotations.ApiStatus; import javax.annotation.Nullable; @@ -45,45 +41,27 @@ static ComputerCraftAPIService get() { String getInstalledVersion(); - int createUniqueNumberedSaveDir(Level world, String parentSubPath); + int createUniqueNumberedSaveDir(MinecraftServer server, String parentSubPath); @Nullable - IWritableMount createSaveDirMount(Level world, String subPath, long capacity); + WritableMount createSaveDirMount(MinecraftServer server, String subPath, long capacity); @Nullable - IMount createResourceMount(String domain, String subPath); - // TODO(1.19.3): Make this take a MinecraftServer argument. - - @Deprecated - default void registerPeripheralProvider(IPeripheralProvider provider) { - throw new UnsupportedOperationException("Can only register peripheral provider on Forge"); - } + Mount createResourceMount(MinecraftServer server, String domain, String subPath); void registerGenericSource(GenericSource source); - @Deprecated - default void registerGenericCapability(Capability capability) { - throw new UnsupportedOperationException("Can only register Capability on Forge"); - } - - void registerBundledRedstoneProvider(IBundledRedstoneProvider provider); + void registerBundledRedstoneProvider(BundledRedstoneProvider provider); int getBundledRedstoneOutput(Level world, BlockPos pos, Direction side); - void registerMediaProvider(IMediaProvider provider); + void registerMediaProvider(MediaProvider provider); - IPacketNetwork getWirelessNetwork(); + PacketNetwork getWirelessNetwork(MinecraftServer server); void registerAPIFactory(ILuaAPIFactory factory); - @Deprecated - void registerDetailProvider(Class type, IDetailProvider provider); - - IWiredNode createWiredNodeForElement(IWiredElement element); - - default LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { - throw new UnsupportedOperationException("Can only call getWiredElementAt on Forge"); - } + WiredNode createWiredNodeForElement(WiredElement element); void registerRefuelHandler(TurtleRefuelHandler handler); diff --git a/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SerialiserWithCraftingItem.java b/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SerialiserWithCraftingItem.java index 2690732bd..db9d2567a 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SerialiserWithCraftingItem.java +++ b/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SerialiserWithCraftingItem.java @@ -6,7 +6,7 @@ package dan200.computercraft.impl.upgrades; import com.google.gson.JsonObject; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import dan200.computercraft.api.upgrades.UpgradeSerialiser; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; @@ -24,7 +24,7 @@ * @param The upgrade that this class can serialise and deserialise. */ @ApiStatus.Internal -public abstract class SerialiserWithCraftingItem implements UpgradeSerialiser { +public abstract class SerialiserWithCraftingItem implements UpgradeSerialiser { private final BiFunction factory; protected SerialiserWithCraftingItem(BiFunction factory) { diff --git a/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SimpleSerialiser.java b/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SimpleSerialiser.java index 66394bd3f..391b33e3a 100644 --- a/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SimpleSerialiser.java +++ b/projects/common-api/src/main/java/dan200/computercraft/impl/upgrades/SimpleSerialiser.java @@ -6,7 +6,7 @@ package dan200.computercraft.impl.upgrades; import com.google.gson.JsonObject; -import dan200.computercraft.api.upgrades.IUpgradeBase; +import dan200.computercraft.api.upgrades.UpgradeBase; import dan200.computercraft.api.upgrades.UpgradeSerialiser; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; @@ -22,7 +22,7 @@ * @param The upgrade that this class can serialise and deserialise. */ @ApiStatus.Internal -public abstract class SimpleSerialiser implements UpgradeSerialiser { +public abstract class SimpleSerialiser implements UpgradeSerialiser { private final Function constructor; public SimpleSerialiser(Function constructor) { diff --git a/projects/common/build.gradle.kts b/projects/common/build.gradle.kts index 90f1a3f59..644f02a6f 100644 --- a/projects/common/build.gradle.kts +++ b/projects/common/build.gradle.kts @@ -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"))) diff --git a/projects/common/src/main/java/dan200/computercraft/data/LanguageProvider.java b/projects/common/src/main/java/dan200/computercraft/data/LanguageProvider.java index eb7008e20..3bcc3e8bb 100644 --- a/projects/common/src/main/java/dan200/computercraft/data/LanguageProvider.java +++ b/projects/common/src/main/java/dan200/computercraft/data/LanguageProvider.java @@ -11,7 +11,7 @@ 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 @@ private Stream getExpectedKeys() { 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) diff --git a/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java b/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java index efef71d23..83b441547 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/AbstractComputerCraftAPI.java @@ -7,21 +7,20 @@ 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 final void registerGenericSource(GenericSource source) { } @Override - public final void registerBundledRedstoneProvider(IBundledRedstoneProvider provider) { + public final void registerBundledRedstoneProvider(BundledRedstoneProvider provider) { BundledRedstone.register(provider); } @@ -88,12 +83,12 @@ public final int getBundledRedstoneOutput(Level world, BlockPos pos, Direction s } @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 final void registerAPIFactory(ILuaAPIFactory factory) { 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 final DetailRegistry getItemStackDetailRegistry() { public final DetailRegistry getBlockInWorldDetailRegistry() { return blockDetails; } - - @Override - @Deprecated - @SuppressWarnings("unchecked") - public void registerDetailProvider(Class type, IDetailProvider provider) { - if (type == ItemStack.class) { - itemStackDetails.addProvider((IDetailProvider) provider); - } else if (type == BlockReference.class) { - blockDetails.addProvider((IDetailProvider) provider); - } else { - throw new IllegalArgumentException("Unknown detail provider " + type); - } - } } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/BundledRedstone.java b/projects/common/src/main/java/dan200/computercraft/impl/BundledRedstone.java index d1b6cfb09..0c571fc36 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/BundledRedstone.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/BundledRedstone.java @@ -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 @@ public final class BundledRedstone { private static final Logger LOG = LoggerFactory.getLogger(BundledRedstone.class); - private static final ArrayList providers = new ArrayList<>(); + private static final ArrayList 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); } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/MediaProviders.java b/projects/common/src/main/java/dan200/computercraft/impl/MediaProviders.java index aa85cce5e..cfb589760 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/MediaProviders.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/MediaProviders.java @@ -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 @@ public final class MediaProviders { private static final Logger LOG = LoggerFactory.getLogger(MediaProviders.class); - private static final Set providers = new LinkedHashSet<>(); + private static final Set 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); } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/UpgradeManager.java b/projects/common/src/main/java/dan200/computercraft/impl/UpgradeManager.java index 254d10405..c5dc8ea46 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/UpgradeManager.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/UpgradeManager.java @@ -7,7 +7,7 @@ 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 @@ * @see TurtleUpgrades * @see PocketUpgrades */ -public class UpgradeManager, T extends IUpgradeBase> extends SimpleJsonResourceReloadListener { +public class UpgradeManager, 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, T extends IUpgradeBase>( + public record UpgradeWrapper, T extends UpgradeBase>( String id, T upgrade, R serialiser, String modId ) { } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/detail/DetailRegistryImpl.java b/projects/common/src/main/java/dan200/computercraft/impl/detail/DetailRegistryImpl.java index 474ebbfe7..3a546731c 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/detail/DetailRegistryImpl.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/detail/DetailRegistryImpl.java @@ -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 @@ * @param The type of object that this registry provides details for. */ public class DetailRegistryImpl implements DetailRegistry { - private final Collection> providers = new ArrayList<>(); - private final IDetailProvider basic; + private final Collection> providers = new ArrayList<>(); + private final DetailProvider basic; - public DetailRegistryImpl(IDetailProvider basic) { + public DetailRegistryImpl(DetailProvider basic) { this.basic = basic; providers.add(basic); } @Override - public synchronized void addProvider(IDetailProvider provider) { + public synchronized void addProvider(DetailProvider provider) { Objects.requireNonNull(provider, "provider cannot be null"); if (!providers.contains(provider)) providers.add(provider); } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/InvariantChecker.java b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/InvariantChecker.java index 8662bdbff..53c113271 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/InvariantChecker.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/InvariantChecker.java @@ -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 static void checkNode(WiredNode node) { } } - public static void checkNetwork(WiredNetwork network) { + public static void checkNetwork(WiredNetworkImpl network) { if (!ENABLED) return; for (var node : network.nodes) checkNode(node); diff --git a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChange.java b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChangeImpl.java similarity index 61% rename from projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChange.java rename to projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChangeImpl.java index 5c6e6b02b..071a573b8 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChange.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkChangeImpl.java @@ -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 removed; private final Map added; - private WiredNetworkChange(Map removed, Map added) { + private WiredNetworkChangeImpl(Map removed, Map added) { this.removed = removed; this.added = added; } - public static WiredNetworkChange changed(Map removed, Map added) { - return new WiredNetworkChange(Collections.unmodifiableMap(removed), Collections.unmodifiableMap(added)); + static WiredNetworkChangeImpl changed(Map removed, Map added) { + return new WiredNetworkChangeImpl(Collections.unmodifiableMap(removed), Collections.unmodifiableMap(added)); } - public static WiredNetworkChange added(Map added) { - return added.isEmpty() ? EMPTY : new WiredNetworkChange(Collections.emptyMap(), Collections.unmodifiableMap(added)); + static WiredNetworkChangeImpl added(Map added) { + return added.isEmpty() ? EMPTY : new WiredNetworkChangeImpl(Collections.emptyMap(), Collections.unmodifiableMap(added)); } - public static WiredNetworkChange removed(Map removed) { - return removed.isEmpty() ? EMPTY : new WiredNetworkChange(Collections.unmodifiableMap(removed), Collections.emptyMap()); + static WiredNetworkChangeImpl removed(Map removed) { + return removed.isEmpty() ? EMPTY : new WiredNetworkChangeImpl(Collections.unmodifiableMap(removed), Collections.emptyMap()); } - public static WiredNetworkChange changeOf(Map oldPeripherals, Map newPeripherals) { + static WiredNetworkChangeImpl changeOf(Map oldPeripherals, Map 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 added = new HashMap<>(newPeripherals); @@ -80,13 +80,13 @@ public boolean isEmpty() { return added.isEmpty() && removed.isEmpty(); } - void broadcast(Iterable nodes) { + void broadcast(Iterable 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); } diff --git a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetwork.java b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkImpl.java similarity index 83% rename from projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetwork.java rename to projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkImpl.java index 111bdb93d..00cf1a5b2 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetwork.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNetworkImpl.java @@ -7,30 +7,30 @@ 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 nodes; + Set nodes; private Map peripherals = new HashMap<>(); - WiredNetwork(WiredNode node) { + WiredNetworkImpl(WiredNodeImpl node) { nodes = new HashSet<>(1); nodes.add(node); } - private WiredNetwork(HashSet nodes) { + private WiredNetworkImpl(HashSet 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 boolean connect(IWiredNode nodeU, IWiredNode nodeV) { 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 boolean connect(IWiredNode nodeU, IWiredNode nodeV) { } @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 boolean disconnect(IWiredNode nodeU, IWiredNode nodeV) { // 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 enqueued = new ArrayDeque<>(); - var reachableU = new HashSet(); + Queue enqueued = new ArrayDeque<>(); + var reachableU = new HashSet(); reachableU.add(wiredU); enqueued.add(wiredU); @@ -127,7 +127,7 @@ public boolean disconnect(IWiredNode nodeU, IWiredNode nodeV) { // 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 boolean disconnect(IWiredNode nodeU, IWiredNode nodeV) { } // 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 boolean disconnect(IWiredNode nodeU, IWiredNode nodeV) { } @Override - public boolean remove(IWiredNode node) { + public boolean remove(WiredNode node) { var wired = checkNode(node); lock.writeLock().lock(); @@ -177,7 +177,7 @@ public boolean remove(IWiredNode node) { 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 boolean remove(IWiredNode node) { // 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(neighbours.size() + 1); + var maximals = new ArrayList(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 boolean remove(IWiredNode node) { // 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 boolean remove(IWiredNode node) { } @Override - public void updatePeripherals(IWiredNode node, Map newPeripherals) { + public void updatePeripherals(WiredNode node, Map newPeripherals) { var wired = checkNode(node); Objects.requireNonNull(peripherals, "peripherals cannot be null"); @@ -258,7 +258,7 @@ public void updatePeripherals(IWiredNode node, Map newPerip 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 void updatePeripherals(IWiredNode node, Map newPerip } } - static void transmitPacket(WiredNode start, Packet packet, double range, boolean interdimensional) { - Map points = new HashMap<>(); + static void transmitPacket(WiredNodeImpl start, Packet packet, double range, boolean interdimensional) { + Map points = new HashMap<>(); var transmitTo = new TreeSet(); { @@ -324,7 +324,7 @@ static void transmitPacket(WiredNode start, Packet packet, double range, boolean } } - 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 @@ private void removeSingleNode(WiredNode wired, WiredNetwork wiredNetwork) { 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 @@ private void removeSingleNode(WiredNode wired, WiredNetwork wiredNetwork) { } private static class TransmitPoint implements Comparable { - 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 int compareTo(TransmitPoint o) { } } - 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 reachableNodes(WiredNode start) { - Queue enqueued = new ArrayDeque<>(); - var reachable = new HashSet(); + private static HashSet reachableNodes(WiredNodeImpl start) { + Queue enqueued = new ArrayDeque<>(); + var reachable = new HashSet(); 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. diff --git a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNode.java b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNodeImpl.java similarity index 70% rename from projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNode.java rename to projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNodeImpl.java index b40793526..38d1b9700 100644 --- a/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNode.java +++ b/projects/common/src/main/java/dan200/computercraft/impl/network/wired/WiredNodeImpl.java @@ -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 receivers; +public final class WiredNodeImpl implements WiredNode { + private @Nullable Set receivers; - final IWiredElement element; + final WiredElement element; Map peripherals = Collections.emptyMap(); - final HashSet neighbours = new HashSet<>(); - volatile WiredNetwork network; + final HashSet 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 boolean isWireless() { @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 void transmitSameDimension(Packet packet, double range) { @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; } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java index f3a4b9737..2cdef53db 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java @@ -7,7 +7,7 @@ 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 @@ /** * Registers ComputerCraft's registry entries and additional objects, such as {@link CauldronInteraction}s and - * {@link IDetailProvider}s + * {@link DetailProvider}s *

* The functions in this class should be called from a loader-specific class. */ diff --git a/projects/common/src/main/java/dan200/computercraft/shared/common/DefaultBundledRedstoneProvider.java b/projects/common/src/main/java/dan200/computercraft/shared/common/DefaultBundledRedstoneProvider.java index d40351911..5a2767d7e 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/common/DefaultBundledRedstoneProvider.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/common/DefaultBundledRedstoneProvider.java @@ -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); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/AbstractComputerBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/AbstractComputerBlockEntity.java index 79ff383b2..11589b403 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/AbstractComputerBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/AbstractComputerBlockEntity.java @@ -314,7 +314,7 @@ public final ServerComputer createServerComputer() { 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); } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java index 3c7f4532e..e68c943a9 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ResourceMount.java @@ -8,7 +8,7 @@ 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.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); /** diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index 00463b152..eedd886d0 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -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 MetricsObserver getMetrics() { } @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); } } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerContext.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerContext.java index efea49910..80e246a19 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerContext.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/core/ServerContext.java @@ -7,7 +7,7 @@ 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.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 ServerComputerRegistry registry() { * * @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 GlobalMetrics metrics() { 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 diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java index 6583a2644..0fbf678d5 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/items/AbstractComputerItem.java @@ -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 boolean setLabel(ItemStack stack, @Nullable String label) { } @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; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/integration/UpgradeRecipeGenerator.java b/projects/common/src/main/java/dan200/computercraft/shared/integration/UpgradeRecipeGenerator.java index 6097aec23..fa214c15a 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/integration/UpgradeRecipeGenerator.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/integration/UpgradeRecipeGenerator.java @@ -9,7 +9,7 @@ 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 @@ private class UpgradeInfo { final Ingredient ingredient; final @Nullable ITurtleUpgrade turtle; final @Nullable IPocketUpgrade pocket; - final IUpgradeBase upgrade; + final UpgradeBase upgrade; private @Nullable ArrayList recipes; UpgradeInfo(ItemStack stack, ITurtleUpgrade turtle) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java b/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java index bca6cebb9..916bc1ad4 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/media/items/DiskItem.java @@ -7,7 +7,7 @@ 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.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 boolean setLabel(ItemStack stack, @Nullable String label) { } @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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java b/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java index 64afeb6f1..d47bb8df7 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/media/items/TreasureDiskItem.java @@ -7,7 +7,7 @@ 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 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 String getLabel(ItemStack stack) { } @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 static ItemStack create(String subPath, int colourIndex) { 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?"; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/network/client/UpgradesLoadedMessage.java b/projects/common/src/main/java/dan200/computercraft/shared/network/client/UpgradesLoadedMessage.java index 3eddba7de..9fb86890e 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/network/client/UpgradesLoadedMessage.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/network/client/UpgradesLoadedMessage.java @@ -9,7 +9,7 @@ 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 UpgradesLoadedMessage(FriendlyByteBuf buf) { pocketUpgrades = fromBytes(buf, PocketUpgradeSerialiser.REGISTRY_ID); } - private , T extends IUpgradeBase> Map> fromBytes( + private , T extends UpgradeBase> Map> fromBytes( FriendlyByteBuf buf, ResourceKey> registryKey ) { var registry = PlatformHelper.get().wrap(registryKey); @@ -71,7 +71,7 @@ public void toBytes(FriendlyByteBuf buf) { toBytes(buf, PocketUpgradeSerialiser.REGISTRY_ID, pocketUpgrades); } - private , T extends IUpgradeBase> void toBytes( + private , T extends UpgradeBase> void toBytes( FriendlyByteBuf buf, ResourceKey> registryKey, Map> upgrades ) { var registry = PlatformHelper.get().wrap(registryKey); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java index 423565536..76b6f7605 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/DiskDriveBlockEntity.java @@ -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 @@ void ejectDisk() { 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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java index 089e90618..a8df9641b 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/MediaStack.java @@ -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 @@ String getAudioTitle() { } @Nullable - public IMount getMount(ServerLevel level) { + public Mount getMount(ServerLevel level) { if (media == null) return null; if (mount == null) mount = media.createDataMount(stack, level); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java index c4f589a40..3d8f2e9ae 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/ModemPeripheral.java @@ -7,10 +7,10 @@ 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 @@ * * */ -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 computers = new HashSet<>(1); private final ModemState state; @@ -96,7 +96,7 @@ public ModemState getModemState() { 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 void receiveDifferentDimension(Packet packet) { } } - protected abstract IPacketNetwork getNetwork(); + protected abstract PacketNetwork getNetwork(); @Override public String getType() { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableBlockEntity.java index 7462c97a2..589ef74d5 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/CableBlockEntity.java @@ -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 @@ protected void detachPeripheral(String name) { 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 Object getTarget() { } }; - private final ComponentAccess connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged()); + private final ComponentAccess connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged()); public CableBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); @@ -309,7 +309,7 @@ private void updateConnectedPeripherals() { } @Nullable - public IWiredElement getWiredElement(@Nullable Direction direction) { + public WiredElement getWiredElement(@Nullable Direction direction) { return direction == null || CableBlock.canConnectIn(getBlockState(), direction) ? cable : null; } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java index 1e559ab39..7fd231426 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemElement.java @@ -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 remotePeripherals = new HashMap<>(); @Override - public IWiredNode getNode() { + public WiredNode getNode() { return node; } @@ -29,7 +29,7 @@ public String getSenderID() { } @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()) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemFullBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemFullBlockEntity.java index 326e0f67f..f1dca00de 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemFullBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemFullBlockEntity.java @@ -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 Vec3 getPosition() { 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 connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged()); + private final ComponentAccess connectedElements = PlatformHelper.get().createWiredElementAccess(x -> connectionsChanged()); private int invalidSides = 0; @@ -278,7 +278,7 @@ private void updateConnectedPeripherals() { node.updatePeripherals(peripherals); } - public IWiredElement getElement() { + public WiredElement getElement() { return element; } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java index 8d7a6db08..a9af955dc 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemPeripheral.java @@ -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.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 double getRange() { } @Override - protected IPacketNetwork getNetwork() { + protected PacketNetwork getNetwork() { return modem.getNode(); } @@ -261,7 +261,7 @@ public boolean equals(@Nullable IPeripheral other) { //endregion @Override - public IWiredNode getNode() { + public WiredNode getNode() { return modem.getNode(); } @@ -368,7 +368,7 @@ public MethodResult callMethod(ILuaContext context, String methodName, IArgument // 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 MethodResult callMethod(ILuaContext context, String methodName, IArgument } @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 MethodResult callMethod(ILuaContext context, String methodName, IArgument } @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 MethodResult callMethod(ILuaContext context, String methodName, IArgument } @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 void queueEvent(String event, @Nullable Object... arguments) { } @Override - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { if (!attached) throw new NotAttachedException(); return computer.getMainThreadMonitor(); } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java index 957b64fff..9bfffc1c2 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessModemPeripheral.java @@ -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 double getRange() { } @Override - protected IPacketNetwork getNetwork() { - return ComputerCraftAPI.getWirelessNetwork(); + protected PacketNetwork getNetwork() { + return ComputerCraftAPI.getWirelessNetwork(Nullability.assertNonNull(getLevel().getServer())); } } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java index 0723deb3f..65808e6dc 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/modem/wireless/WirelessNetwork.java @@ -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.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 static void resetNetworks() { universalNetwork = null; } - private final Set receivers = Collections.newSetFromMap(new ConcurrentHashMap<>()); + private final Set 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 void transmitInterdimensional(Packet packet) { 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 diff --git a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java index e1b9bc890..8793f9010 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/platform/PlatformHelper.java @@ -7,7 +7,7 @@ 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.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 @@ static PlatformHelper get() { * include all changes, and so block updates should still be listened to. * @return The peripheral component access. */ - ComponentAccess createWiredElementAccess(Consumer invalidate); + ComponentAccess createWiredElementAccess(Consumer invalidate); /** * Determine if there is a wired element in the given direction. This is equivalent to @@ -239,18 +238,6 @@ static PlatformHelper get() { @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. * diff --git a/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java b/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java index f8fc88455..89192c2c6 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/pocket/items/PocketComputerItem.java @@ -8,7 +8,7 @@ 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 String getCreatorModId(ItemStack stack) { 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 PocketServerComputer createServerComputer(ServerLevel world, Entity entit if (inventory != null) inventory.setChanged(); } - computer.setLevel(world); + computer.setLevel(level); return computer; } @@ -265,10 +263,10 @@ public boolean setLabel(ItemStack stack, @Nullable String label) { } @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; } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index 81400f4ba..7c124d805 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -8,7 +8,7 @@ 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 String[] getNames() { return new String[]{ "turtle" }; } - private MethodResult trackCommand(ITurtleCommand command) { + private MethodResult trackCommand(TurtleCommand command) { environment.observe(Metrics.TURTLE_OPS); return turtle.executeCommand(command); } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java index 9b71ca89c..b0d251b16 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleBrain.java @@ -18,7 +18,6 @@ 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.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 Container getInventory() { 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 void addFuel(int fuel) { } @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"); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCommandQueueEntry.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCommandQueueEntry.java index c99d02130..badb81f38 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCommandQueueEntry.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCommandQueueEntry.java @@ -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) { } diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java index 539d8df86..fb21b38df 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java index dfeae43b5..b9779e324 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareToCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java index 27c7eb798..e3c9db548 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCraftCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDetectCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDetectCommand.java index d38678d84..5cc5fd352 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDetectCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDetectCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java index 8d53cdfac..441f1a6bf 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleDropCommand.java @@ -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 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; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java index 3ee641128..a9fb5d7c5 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleEquipCommand.java @@ -10,7 +10,7 @@ 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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleInspectCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleInspectCommand.java index 0293fe75e..c79f31be7 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleInspectCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleInspectCommand.java @@ -8,10 +8,10 @@ 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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleMoveCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleMoveCommand.java index 8d3fb851e..f251b3485 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleMoveCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleMoveCommand.java @@ -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.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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index 02c0aec25..ca9c5ffaa 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -7,8 +7,8 @@ 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 javax.annotation.Nullable; -public class TurtlePlaceCommand implements ITurtleCommand { +public class TurtlePlaceCommand implements TurtleCommand { private final InteractDirection direction; private final Object[] extraArguments; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java index 1345b6320..e7c1a3539 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleRefuelCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java index b79ae20ce..1dcaeaa75 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleSuckCommand.java @@ -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.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; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java index 492d36405..caa642093 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleToolCommand.java @@ -10,7 +10,7 @@ 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; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java index 562ae5bac..82662157b 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTransferToCommand.java @@ -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; diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java index cc592cb55..73ccd74db 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/core/TurtleTurnCommand.java @@ -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) { diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleToolSerialiser.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleToolSerialiser.java index 9b15eb3b5..e9eed2af9 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleToolSerialiser.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/upgrades/TurtleToolSerialiser.java @@ -7,7 +7,7 @@ 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 @@ private TurtleToolSerialiser() { @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); diff --git a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java index f27d3df2a..a9ed46e33 100644 --- a/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java +++ b/projects/common/src/test/java/dan200/computercraft/TestPlatformHelper.java @@ -8,8 +8,8 @@ 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 ComponentAccess createPeripheralAccess(Consumer i } @Override - public ComponentAccess createWiredElementAccess(Consumer invalidate) { + public ComponentAccess createWiredElementAccess(Consumer invalidate) { throw new UnsupportedOperationException("Cannot interact with the world inside tests"); } @@ -226,7 +226,7 @@ public String getInstalledVersion() { @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"); } diff --git a/projects/common/src/test/java/dan200/computercraft/impl/network/wired/NetworkTest.java b/projects/common/src/test/java/dan200/computercraft/impl/network/wired/NetworkTest.java index c6e479a56..5cbdb6465 100644 --- a/projects/common/src/test/java/dan200/computercraft/impl/network/wired/NetworkTest.java +++ b/projects/common/src/test/java/dan200/computercraft/impl/network/wired/NetworkTest.java @@ -8,10 +8,10 @@ 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 void testConnect() { 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 void testDisconnectNoChange() { 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 void testDisconnectLeaf() { 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 void testDisconnectSplit() { 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 void testRemoveLeaf() { 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 void testRemoveSplit() { 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 void testRemoveSplit() { @Test @Disabled("Takes a long time to run, mostly for stress testing") public void testLarge() { - var grid = new Grid(BRUTE_SIZE); + var grid = new Grid(BRUTE_SIZE); grid.map((existing, pos) -> new NetworkElement(null, null, "n_" + pos).getNode()); // Test connecting @@ -297,11 +297,11 @@ public void testLarge() { } } - 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 localPeripherals = Maps.newHashMap(); private final Map remotePeripherals = Maps.newHashMap(); @@ -334,12 +334,12 @@ public String toString() { } @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 void map(BiFunction transform) { } } - private static Set nodes(IWiredNetwork network) { - return ((WiredNetwork) network).nodes; + private static Set nodes(WiredNetwork network) { + return ((WiredNetworkImpl) network).nodes; } - private static Set neighbours(IWiredNode node) { - return ((WiredNode) node).neighbours; + private static Set neighbours(WiredNode node) { + return ((WiredNodeImpl) node).neighbours; } } diff --git a/projects/common/src/test/java/dan200/computercraft/shared/computer/core/ResourceMountTest.java b/projects/common/src/test/java/dan200/computercraft/shared/computer/core/ResourceMountTest.java index b9b6bc36b..32f7ff5fa 100644 --- a/projects/common/src/test/java/dan200/computercraft/shared/computer/core/ResourceMountTest.java +++ b/projects/common/src/test/java/dan200/computercraft/shared/computer/core/ResourceMountTest.java @@ -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 static org.junit.jupiter.api.Assertions.*; public class ResourceMountTest { - private IMount mount; + private Mount mount; @BeforeEach public void before() { diff --git a/projects/core-api/build.gradle.kts b/projects/core-api/build.gradle.kts index b60c52b96..103606164 100644 --- a/projects/core-api/build.gradle.kts +++ b/projects/core-api/build.gradle.kts @@ -14,7 +14,6 @@ val docApi by configurations.registering { } dependencies { - compileOnly(project(":mc-stubs")) compileOnlyApi(libs.jsr305) compileOnlyApi(libs.checkerFramework) compileOnlyApi(libs.jetbrainsAnnotations) diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java index 16f44df1c..7efa5b249 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileAttributes.java @@ -11,7 +11,7 @@ import java.time.Instant; /** - * A simple version of {@link BasicFileAttributes}, which provides what information a {@link IMount} already exposes. + * A simple version of {@link BasicFileAttributes}, which provides what information a {@link Mount} already exposes. * * @param isDirectory Whether this filesystem entry is a directory. * @param size The size of the file. diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java index 81d5e20a6..e249f484b 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/FileOperationException.java @@ -13,7 +13,7 @@ /** * An {@link IOException} which occurred on a specific file. *

- * This may be thrown from a {@link IMount} or {@link IWritableMount} to give more information about a failure. + * This may be thrown from a {@link Mount} or {@link WritableMount} to give more information about a failure. */ public class FileOperationException extends IOException { @Serial diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java deleted file mode 100644 index 847c22ce9..000000000 --- a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IFileSystem.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the public ComputerCraft API - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only. - * For help using the API, and posting your mods, visit the forums at computercraft.info. - */ -package dan200.computercraft.api.filesystem; - -import java.io.IOException; - -/** - * Provides a mount of the entire computer's file system. - *

- * This exists for use by various APIs - one should not attempt to mount it. - */ -public interface IFileSystem extends IWritableMount { - /** - * Combine two paths together, reducing them into a normalised form. - * - * @param path The main path. - * @param child The path to append. - * @return The combined, normalised path. - */ - String combine(String path, String child); - - /** - * Copy files from one location to another. - * - * @param from The location to copy from. - * @param to The location to copy to. This should not exist. - * @throws IOException If the copy failed. - */ - void copy(String from, String to) throws IOException; - - /** - * Move files from one location to another. - * - * @param from The location to move from. - * @param to The location to move to. This should not exist. - * @throws IOException If the move failed. - */ - void move(String from, String to) throws IOException; -} diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/Mount.java similarity index 96% rename from projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/Mount.java index ecfac348a..7008f2c20 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IMount.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/Mount.java @@ -14,15 +14,15 @@ /** * Represents a read only part of a virtual filesystem that can be mounted onto a computer using - * {@link IComputerAccess#mount(String, IMount)}. + * {@link IComputerAccess#mount(String, Mount)}. *

* Typically you will not need to implement this interface yourself, and can use the factory methods from the * {@linkplain dan200.computercraft.api.ComputerCraftAPI the main ComputerCraft API}. * - * @see IComputerAccess#mount(String, IMount) - * @see IWritableMount + * @see IComputerAccess#mount(String, Mount) + * @see WritableMount */ -public interface IMount { +public interface Mount { /** * Returns whether a file with a given path exists or not. * diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/WritableMount.java similarity index 91% rename from projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java rename to projects/core-api/src/main/java/dan200/computercraft/api/filesystem/WritableMount.java index 1bebaf3e8..c30a6845c 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/filesystem/WritableMount.java @@ -13,17 +13,17 @@ import java.util.OptionalLong; /** - * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, IMount)} - * or {@link IComputerAccess#mountWritable(String, IWritableMount)}, that can also be written to. + * Represents a part of a virtual filesystem that can be mounted onto a computer using {@link IComputerAccess#mount(String, Mount)} + * or {@link IComputerAccess#mountWritable(String, WritableMount)}, that can also be written to. *

* Typically you will not need to implement this interface yourself, and can use the factory methods from the * {@linkplain dan200.computercraft.api.ComputerCraftAPI the main ComputerCraft API}. * - * @see IComputerAccess#mount(String, IMount) - * @see IComputerAccess#mountWritable(String, IWritableMount) - * @see IMount + * @see IComputerAccess#mount(String, Mount) + * @see IComputerAccess#mountWritable(String, WritableMount) + * @see Mount */ -public interface IWritableMount extends IMount { +public interface WritableMount extends Mount { /** * Creates a directory at a given path inside the virtual file system. * diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java index 3fd684ce0..9dfe28ada 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/GenericSource.java @@ -7,7 +7,6 @@ import dan200.computercraft.api.peripheral.GenericPeripheral; import dan200.computercraft.api.peripheral.IPeripheral; -import net.minecraft.resources.ResourceLocation; /** * A generic source of {@link LuaFunction} functions. @@ -44,10 +43,10 @@ public interface GenericSource { /** * A unique identifier for this generic source. *

- * This is currently unused, but may be used in the future to allow disabling specific sources. It is recommended - * to return an identifier using your mod's ID. + * While this can return an arbitrary string, it's recommended that this is formatted the same was as Minecraft's + * resource locations/identifiers, so is of the form {@code "mod_id:source_id"}. * * @return This source's identifier. */ - ResourceLocation id(); + String id(); } diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java index 278000a74..3165fb8f2 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/IComputerSystem.java @@ -5,7 +5,6 @@ */ package dan200.computercraft.api.lua; -import dan200.computercraft.api.filesystem.IFileSystem; import dan200.computercraft.api.peripheral.IComputerAccess; import javax.annotation.Nullable; @@ -15,14 +14,6 @@ * about a computer. */ public interface IComputerSystem extends IComputerAccess { - /** - * Get the file system for this computer. - * - * @return The computer's file system, or {@code null} if it is not initialised. - */ - @Nullable - IFileSystem getFileSystem(); - /** * Get the label for this computer. * diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java index c47568d20..0b1e73bb2 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaContext.java @@ -23,7 +23,7 @@ public interface ILuaContext { * @throws LuaException If the task could not be queued. * @see LuaFunction#mainThread() To run functions on the main thread and return their results synchronously. */ - long issueMainThreadTask(ILuaTask task) throws LuaException; + long issueMainThreadTask(LuaTask task) throws LuaException; /** * Queue a task to be executed on the main server thread at the beginning of next tick, waiting for it to complete. @@ -36,7 +36,7 @@ public interface ILuaContext { * @return The objects returned by {@code task}. * @throws LuaException If the task could not be queued, or if the task threw an exception. */ - default MethodResult executeMainThreadTask(ILuaTask task) throws LuaException { + default MethodResult executeMainThreadTask(LuaTask task) throws LuaException { return TaskCallback.make(this, task); } } diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java index dcaeddd0c..bd7895a9a 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaFunction.java @@ -51,7 +51,7 @@ * Minecraft in a thread-unsafe manner. * * @return Whether this function should be run on the main thread. - * @see ILuaContext#issueMainThreadTask(ILuaTask) + * @see ILuaContext#issueMainThreadTask(LuaTask) */ boolean mainThread() default false; diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaTask.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTask.java similarity index 88% rename from projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaTask.java rename to projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTask.java index b91091492..9b5df3530 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/ILuaTask.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/LuaTask.java @@ -8,14 +8,14 @@ import javax.annotation.Nullable; /** - * A task which can be executed via {@link ILuaContext#issueMainThreadTask(ILuaTask)} This will be run on the main + * A task which can be executed via {@link ILuaContext#issueMainThreadTask(LuaTask)} This will be run on the main * thread, at the beginning of the * next tick. * - * @see ILuaContext#issueMainThreadTask(ILuaTask) + * @see ILuaContext#issueMainThreadTask(LuaTask) */ @FunctionalInterface -public interface ILuaTask { +public interface LuaTask { /** * Execute this task. * diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java b/projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java index fe62c7cd8..209df9264 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/lua/TaskCallback.java @@ -34,7 +34,7 @@ public MethodResult resume(Object[] response) throws LuaException { } } - static MethodResult make(ILuaContext context, ILuaTask func) throws LuaException { + static MethodResult make(ILuaContext context, LuaTask func) throws LuaException { var task = context.issueMainThreadTask(func); return new TaskCallback(task).pull; } diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java index 814a251f9..7cc33fa15 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IComputerAccess.java @@ -5,11 +5,11 @@ */ package dan200.computercraft.api.peripheral; -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.ILuaCallback; import dan200.computercraft.api.lua.ILuaContext; -import dan200.computercraft.api.lua.ILuaTask; +import dan200.computercraft.api.lua.LuaTask; import dan200.computercraft.api.lua.MethodResult; import javax.annotation.Nullable; @@ -29,13 +29,13 @@ public interface IComputerAccess { * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see #mount(String, IMount, String) - * @see #mountWritable(String, IWritableMount) + * @see #mount(String, Mount, String) + * @see #mountWritable(String, WritableMount) * @see #unmount(String) - * @see IMount + * @see Mount */ @Nullable - default String mount(String desiredLocation, IMount mount) { + default String mount(String desiredLocation, Mount mount) { return mount(desiredLocation, mount, getAttachmentName()); } @@ -48,13 +48,13 @@ default String mount(String desiredLocation, IMount mount) { * @return The location on the computer's file system where you the mount mounted, or {@code null} if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see #mount(String, IMount) - * @see #mountWritable(String, IWritableMount) + * @see #mount(String, Mount) + * @see #mountWritable(String, WritableMount) * @see #unmount(String) - * @see IMount + * @see Mount */ @Nullable - String mount(String desiredLocation, IMount mount, String driveName); + String mount(String desiredLocation, Mount mount, String driveName); /** * Mount a mount onto the computer's file system in a writable mode. @@ -64,12 +64,12 @@ default String mount(String desiredLocation, IMount mount) { * @return The location on the computer's file system where you the mount mounted, or null if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see #mount(String, IMount) + * @see #mount(String, Mount) * @see #unmount(String) - * @see IMount + * @see Mount */ @Nullable - default String mountWritable(String desiredLocation, IWritableMount mount) { + default String mountWritable(String desiredLocation, WritableMount mount) { return mountWritable(desiredLocation, mount, getAttachmentName()); } @@ -82,16 +82,16 @@ default String mountWritable(String desiredLocation, IWritableMount mount) { * @return The location on the computer's file system where you the mount mounted, or null if there was already a * file in the desired location. Store this value if you wish to unmount the mount later. * @throws NotAttachedException If the peripheral has been detached. - * @see #mount(String, IMount) + * @see #mount(String, Mount) * @see #unmount(String) - * @see IMount + * @see Mount */ @Nullable - String mountWritable(String desiredLocation, IWritableMount mount, String driveName); + String mountWritable(String desiredLocation, WritableMount mount, String driveName); /** - * Unmounts a directory previously mounted onto the computers file system by {@link #mount(String, IMount)} - * or {@link #mountWritable(String, IWritableMount)}. + * Unmounts a directory previously mounted onto the computers file system by {@link #mount(String, Mount)} + * or {@link #mountWritable(String, WritableMount)}. *

* When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be * able to access it. All directories mounted by a mount or mountWritable are automatically unmounted when the @@ -100,12 +100,12 @@ default String mountWritable(String desiredLocation, IWritableMount mount) { * Note that you cannot unmount another peripheral's mounts. * * @param location The desired location in the computers file system of the directory to unmount. - * This must be the location of a directory previously mounted by {@link #mount(String, IMount)} or - * {@link #mountWritable(String, IWritableMount)}, as indicated by their return value. + * This must be the location of a directory previously mounted by {@link #mount(String, Mount)} or + * {@link #mountWritable(String, WritableMount)}, as indicated by their return value. * @throws NotAttachedException If the peripheral has been detached. * @throws IllegalStateException If the mount does not exist, or was mounted by another peripheral. - * @see #mount(String, IMount) - * @see #mountWritable(String, IWritableMount) + * @see #mount(String, Mount) + * @see #mountWritable(String, WritableMount) */ void unmount(@Nullable String location); @@ -175,11 +175,11 @@ default String mountWritable(String desiredLocation, IWritableMount mount) { IPeripheral getAvailablePeripheral(String name); /** - * Get a {@link IWorkMonitor} for tasks your peripheral might execute on the main (server) thread. + * Get a {@link WorkMonitor} for tasks your peripheral might execute on the main (server) thread. *

* This should be used to ensure your peripheral integrates with ComputerCraft's monitoring and limiting of how much * server time each computer consumes. You should not need to use this if you use - * {@link ILuaContext#issueMainThreadTask(ILuaTask)} - this is intended for mods with their own system for running + * {@link ILuaContext#issueMainThreadTask(LuaTask)} - this is intended for mods with their own system for running * work on the main thread. *

* Please note that the returned implementation is not thread-safe, and should only be used from the main @@ -188,5 +188,5 @@ default String mountWritable(String desiredLocation, IWritableMount mount) { * @return The work monitor for the main thread, or {@code null} if this computer does not have one. * @throws NotAttachedException If the peripheral has been detached. */ - IWorkMonitor getMainThreadMonitor(); + WorkMonitor getMainThreadMonitor(); } diff --git a/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/WorkMonitor.java similarity index 98% rename from projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java rename to projects/core-api/src/main/java/dan200/computercraft/api/peripheral/WorkMonitor.java index cd31314a5..2c856fab5 100644 --- a/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/IWorkMonitor.java +++ b/projects/core-api/src/main/java/dan200/computercraft/api/peripheral/WorkMonitor.java @@ -23,7 +23,7 @@ * * @see IComputerAccess#getMainThreadMonitor() */ -public interface IWorkMonitor { +public interface WorkMonitor { /** * If the owning computer is currently allowed to execute work. * diff --git a/projects/core/src/main/java/dan200/computercraft/core/apis/ComputerAccess.java b/projects/core/src/main/java/dan200/computercraft/core/apis/ComputerAccess.java index 3a04d636c..baffd6dfc 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/apis/ComputerAccess.java +++ b/projects/core/src/main/java/dan200/computercraft/core/apis/ComputerAccess.java @@ -5,10 +5,10 @@ */ package dan200.computercraft.core.apis; -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.peripheral.IComputerAccess; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.filesystem.FileSystemException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,7 +42,7 @@ public void unmountAll() { @Nullable @Override - public synchronized String mount(String desiredLoc, IMount mount, String driveName) { + public synchronized String mount(String desiredLoc, Mount mount, String driveName) { Objects.requireNonNull(desiredLoc, "desiredLocation cannot be null"); Objects.requireNonNull(mount, "mount cannot be null"); Objects.requireNonNull(driveName, "driveName cannot be null"); @@ -68,7 +68,7 @@ public synchronized String mount(String desiredLoc, IMount mount, String driveNa @Nullable @Override - public synchronized String mountWritable(String desiredLoc, IWritableMount mount, String driveName) { + public synchronized String mountWritable(String desiredLoc, WritableMount mount, String driveName) { Objects.requireNonNull(desiredLoc, "desiredLocation cannot be null"); Objects.requireNonNull(mount, "mount cannot be null"); Objects.requireNonNull(driveName, "driveName cannot be null"); @@ -113,7 +113,7 @@ public void queueEvent(String event, @Nullable Object... arguments) { } @Override - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { return environment.getMainThreadMonitor(); } diff --git a/projects/core/src/main/java/dan200/computercraft/core/apis/IAPIEnvironment.java b/projects/core/src/main/java/dan200/computercraft/core/apis/IAPIEnvironment.java index f98d18a24..34d893058 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/apis/IAPIEnvironment.java +++ b/projects/core/src/main/java/dan200/computercraft/core/apis/IAPIEnvironment.java @@ -6,7 +6,7 @@ package dan200.computercraft.core.apis; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.computer.ComputerEnvironment; import dan200.computercraft.core.computer.ComputerSide; import dan200.computercraft.core.computer.GlobalEnvironment; @@ -30,7 +30,7 @@ interface IPeripheralChangeListener { GlobalEnvironment getGlobalEnvironment(); - IWorkMonitor getMainThreadMonitor(); + WorkMonitor getMainThreadMonitor(); Terminal getTerminal(); diff --git a/projects/core/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java b/projects/core/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java index 68750a3a9..e62a97634 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java +++ b/projects/core/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java @@ -5,13 +5,13 @@ */ package dan200.computercraft.core.apis; -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.peripheral.IDynamicPeripheral; 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.asm.LuaMethod; import dan200.computercraft.core.asm.PeripheralMethod; import dan200.computercraft.core.computer.ComputerSide; @@ -101,14 +101,14 @@ public MethodResult call(ILuaContext context, String methodName, IArguments argu @Nullable @Override - public synchronized String mount(String desiredLoc, IMount mount, String driveName) { + public synchronized String mount(String desiredLoc, Mount mount, String driveName) { if (!attached) throw new NotAttachedException(); return super.mount(desiredLoc, mount, driveName); } @Nullable @Override - public synchronized String mountWritable(String desiredLoc, IWritableMount mount, String driveName) { + public synchronized String mountWritable(String desiredLoc, WritableMount mount, String driveName) { if (!attached) throw new NotAttachedException(); return super.mountWritable(desiredLoc, mount, driveName); } @@ -165,7 +165,7 @@ public IPeripheral getAvailablePeripheral(String name) { } @Override - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { if (!attached) throw new NotAttachedException(); return super.getMainThreadMonitor(); } diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/Computer.java b/projects/core/src/main/java/dan200/computercraft/core/computer/Computer.java index 2304379d2..4674c3843 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -8,8 +8,8 @@ import com.google.common.base.Objects; import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.lua.ILuaContext; -import dan200.computercraft.api.lua.ILuaTask; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.lua.LuaTask; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.ComputerContext; import dan200.computercraft.core.apis.IAPIEnvironment; import dan200.computercraft.core.computer.mainthread.MainThreadScheduler; @@ -47,9 +47,9 @@ public class Computer { private final MainThreadScheduler.Executor serverExecutor; /** - * An internal counter for {@link ILuaTask} ids. + * An internal counter for {@link LuaTask} ids. * - * @see ILuaContext#issueMainThreadTask(ILuaTask) + * @see ILuaContext#issueMainThreadTask(LuaTask) * @see #getUniqueTaskId() */ private final AtomicLong lastTaskId = new AtomicLong(); @@ -127,7 +127,7 @@ public boolean queueMainThread(Runnable runnable) { return serverExecutor.enqueue(runnable); } - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { return serverExecutor; } diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerEnvironment.java b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerEnvironment.java index 6347b8cd6..6cf30e5a0 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerEnvironment.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerEnvironment.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core.computer; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import dan200.computercraft.core.filesystem.FileMount; import dan200.computercraft.core.metrics.MetricsObserver; @@ -41,5 +41,5 @@ public interface ComputerEnvironment { * @see FileMount */ @Nullable - IWritableMount createRootMount(); + WritableMount createRootMount(); } diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerExecutor.java b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerExecutor.java index ff54c5667..321533829 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerExecutor.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerExecutor.java @@ -5,8 +5,8 @@ */ package dan200.computercraft.core.computer; -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.ILuaAPI; import dan200.computercraft.core.ComputerContext; import dan200.computercraft.core.CoreConfig; @@ -150,7 +150,7 @@ final class ComputerExecutor { */ private boolean closed; - private @Nullable IWritableMount rootMount; + private @Nullable WritableMount rootMount; /** * The thread the executor is running on. This is non-null when performing work. We use this to ensure we're only @@ -323,12 +323,12 @@ void tick() { } @Nullable - private IMount getRomMount() { + private Mount getRomMount() { return computer.getGlobalEnvironment().createResourceMount("computercraft", "lua/rom"); } @Nullable - private IWritableMount getRootMount() { + private WritableMount getRootMount() { if (rootMount == null) rootMount = computerEnvironment.createRootMount(); return rootMount; } diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerSystem.java b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerSystem.java index 1d3cb161f..a19ded2dc 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerSystem.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/ComputerSystem.java @@ -5,7 +5,6 @@ */ package dan200.computercraft.core.computer; -import dan200.computercraft.api.filesystem.IFileSystem; import dan200.computercraft.api.lua.IComputerSystem; import dan200.computercraft.api.lua.ILuaAPIFactory; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -37,13 +36,6 @@ public String getAttachmentName() { return "computer"; } - @Nullable - @Override - public IFileSystem getFileSystem() { - var fs = environment.getFileSystem(); - return fs == null ? null : fs.getMountWrapper(); - } - @Nullable @Override public String getLabel() { diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/Environment.java b/projects/core/src/main/java/dan200/computercraft/core/computer/Environment.java index ab523aad0..76b6a9a95 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/Environment.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/Environment.java @@ -7,7 +7,7 @@ import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.apis.IAPIEnvironment; import dan200.computercraft.core.filesystem.FileSystem; import dan200.computercraft.core.metrics.Metric; @@ -83,7 +83,7 @@ public GlobalEnvironment getGlobalEnvironment() { } @Override - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { return computer.getMainThreadMonitor(); } diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/GlobalEnvironment.java b/projects/core/src/main/java/dan200/computercraft/core/computer/GlobalEnvironment.java index 7f7cc9031..2baf9d855 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/GlobalEnvironment.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/GlobalEnvironment.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core.computer; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.filesystem.Mount; import javax.annotation.Nullable; import java.io.InputStream; @@ -38,7 +38,7 @@ public interface GlobalEnvironment { * @return The created mount or {@code null} if it could not be created. */ @Nullable - IMount createResourceMount(String domain, String subPath); + Mount createResourceMount(String domain, String subPath); /** * Open a single mod-provided file. diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/LuaContext.java b/projects/core/src/main/java/dan200/computercraft/core/computer/LuaContext.java index 3bb209456..c1ba7e072 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/LuaContext.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/LuaContext.java @@ -6,8 +6,8 @@ package dan200.computercraft.core.computer; import dan200.computercraft.api.lua.ILuaContext; -import dan200.computercraft.api.lua.ILuaTask; import dan200.computercraft.api.lua.LuaException; +import dan200.computercraft.api.lua.LuaTask; import dan200.computercraft.core.Logging; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,7 +22,7 @@ class LuaContext implements ILuaContext { } @Override - public long issueMainThreadTask(final ILuaTask task) throws LuaException { + public long issueMainThreadTask(final LuaTask task) throws LuaException { // Issue command final var taskID = computer.getUniqueTaskId(); final Runnable iTask = () -> { diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadExecutor.java b/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadExecutor.java index cccc080ac..98c7432c2 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadExecutor.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadExecutor.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core.computer.mainthread; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.CoreConfig; import dan200.computercraft.core.computer.Computer; import dan200.computercraft.core.metrics.Metrics; @@ -28,7 +28,7 @@ * time-frame or the global time frame has expired. *

* Then, when other objects (such as block entities or entities) are ticked, we update how much time we've used via - * {@link IWorkMonitor#trackWork(long, TimeUnit)}. + * {@link WorkMonitor#trackWork(long, TimeUnit)}. *

* Now, if anywhere during this period, we use more than our allocated time slice, the executor is marked as * {@link State#HOT}. This means it will no longer be able to execute {@link MainThread} tasks (though will still @@ -44,7 +44,7 @@ * second, but one task source will not prevent others from executing. * * @see MainThread - * @see IWorkMonitor + * @see WorkMonitor * @see Computer#getMainThreadMonitor() * @see Computer#queueMainThread(Runnable) */ diff --git a/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadScheduler.java b/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadScheduler.java index 2601013bf..21ce570c7 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadScheduler.java +++ b/projects/core/src/main/java/dan200/computercraft/core/computer/mainthread/MainThreadScheduler.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core.computer.mainthread; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.metrics.MetricsObserver; import java.util.OptionalLong; @@ -28,7 +28,7 @@ public interface MainThreadScheduler { /** * An {@link Executor} is responsible for managing scheduled tasks for a single computer. */ - interface Executor extends IWorkMonitor { + interface Executor extends WorkMonitor { /** * Schedule a task to be run on the main thread. This can be called from any thread. * diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileMount.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileMount.java index c5d393ad7..41cc542f2 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileMount.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileMount.java @@ -7,7 +7,7 @@ import com.google.common.collect.Sets; import dan200.computercraft.api.filesystem.FileOperationException; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,7 +22,7 @@ import java.util.OptionalLong; import java.util.Set; -public class FileMount implements IWritableMount { +public class FileMount implements WritableMount { private static final Logger LOG = LoggerFactory.getLogger(FileMount.class); private static final long MINIMUM_FILE_SIZE = 500; private static final Set READ_OPTIONS = Collections.singleton(StandardOpenOption.READ); diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java index 2fa8a54b5..3eb163973 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystem.java @@ -7,9 +7,8 @@ import com.google.common.base.Splitter; import com.google.common.io.ByteStreams; -import dan200.computercraft.api.filesystem.IFileSystem; -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.core.CoreConfig; import dan200.computercraft.core.util.IoUtil; @@ -36,17 +35,16 @@ public class FileSystem { */ private static final int MAX_COPY_DEPTH = 128; - private final FileSystemWrapperMount wrapper = new FileSystemWrapperMount(this); private final Map mounts = new HashMap<>(); private final HashMap>, ChannelWrapper> openFiles = new HashMap<>(); private final ReferenceQueue> openFileQueue = new ReferenceQueue<>(); - public FileSystem(String rootLabel, IMount rootMount) throws FileSystemException { + public FileSystem(String rootLabel, Mount rootMount) throws FileSystemException { mount(rootLabel, "", rootMount); } - public FileSystem(String rootLabel, IWritableMount rootMount) throws FileSystemException { + public FileSystem(String rootLabel, WritableMount rootMount) throws FileSystemException { mountWritable(rootLabel, "", rootMount); } @@ -59,14 +57,14 @@ public void close() { } } - public synchronized void mount(String label, String location, IMount mount) throws FileSystemException { + public synchronized void mount(String label, String location, Mount mount) throws FileSystemException { Objects.requireNonNull(mount, "mount cannot be null"); location = sanitizePath(location); if (location.contains("..")) throw new FileSystemException("Cannot mount below the root"); mount(new MountWrapper(label, location, mount)); } - public synchronized void mountWritable(String label, String location, IWritableMount mount) throws FileSystemException { + public synchronized void mountWritable(String label, String location, WritableMount mount) throws FileSystemException { Objects.requireNonNull(mount, "mount cannot be null"); location = sanitizePath(location); @@ -399,10 +397,6 @@ private synchronized MountWrapper getMount(String path) throws FileSystemExcepti return match; } - public IFileSystem getMountWrapper() { - return wrapper; - } - private static String sanitizePath(String path) { return sanitizePath(path, false); } diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java deleted file mode 100644 index 0ec038aa9..000000000 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/FileSystemWrapperMount.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package dan200.computercraft.core.filesystem; - -import dan200.computercraft.api.filesystem.IFileSystem; - -import java.io.IOException; -import java.nio.channels.ReadableByteChannel; -import java.nio.channels.WritableByteChannel; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -public class FileSystemWrapperMount implements IFileSystem { - private final FileSystem filesystem; - - public FileSystemWrapperMount(FileSystem filesystem) { - this.filesystem = filesystem; - } - - @Override - public void makeDirectory(String path) throws IOException { - try { - filesystem.makeDir(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public void delete(String path) throws IOException { - try { - filesystem.delete(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public ReadableByteChannel openForRead(String path) throws IOException { - try { - // FIXME: Think of a better way of implementing this, so closing this will close on the computer. - return filesystem.openForRead(path, Function.identity()).get(); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public WritableByteChannel openForWrite(String path) throws IOException { - try { - return filesystem.openForWrite(path, false, Function.identity()).get(); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public WritableByteChannel openForAppend(String path) throws IOException { - try { - return filesystem.openForWrite(path, true, Function.identity()).get(); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public long getRemainingSpace() throws IOException { - try { - return filesystem.getFreeSpace("/"); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public boolean exists(String path) throws IOException { - try { - return filesystem.exists(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public boolean isDirectory(String path) throws IOException { - try { - return filesystem.isDir(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public boolean isReadOnly(String path) throws IOException { - try { - return filesystem.isReadOnly(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public void list(String path, List contents) throws IOException { - try { - Collections.addAll(contents, filesystem.list(path)); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public long getSize(String path) throws IOException { - try { - return filesystem.getSize(path); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public String combine(String path, String child) { - return filesystem.combine(path, child); - } - - @Override - public void copy(String from, String to) throws IOException { - try { - filesystem.copy(from, to); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } - - @Override - public void move(String from, String to) throws IOException { - try { - filesystem.move(from, to); - } catch (FileSystemException e) { - throw new IOException(e.getMessage()); - } - } -} diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/JarMount.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/JarMount.java index 524c75439..49fd103e7 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/JarMount.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/JarMount.java @@ -10,7 +10,7 @@ import com.google.common.io.ByteStreams; import com.google.errorprone.annotations.concurrent.LazyInit; import dan200.computercraft.api.filesystem.FileOperationException; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.filesystem.Mount; import dan200.computercraft.core.apis.handles.ArrayByteChannel; import dan200.computercraft.core.util.IoUtil; @@ -33,7 +33,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -public class JarMount implements IMount { +public class JarMount implements Mount { /** * Only cache files smaller than 1MiB. */ diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/MountWrapper.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/MountWrapper.java index ed9a818ed..1135bc4d0 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/MountWrapper.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/MountWrapper.java @@ -6,8 +6,8 @@ package dan200.computercraft.core.filesystem; import dan200.computercraft.api.filesystem.FileOperationException; -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 javax.annotation.Nullable; import java.io.IOException; @@ -22,17 +22,17 @@ class MountWrapper { private final String label; private final String location; - private final IMount mount; - private final @Nullable IWritableMount writableMount; + private final Mount mount; + private final @Nullable WritableMount writableMount; - MountWrapper(String label, String location, IMount mount) { + MountWrapper(String label, String location, Mount mount) { this.label = label; this.location = location; this.mount = mount; writableMount = null; } - MountWrapper(String label, String location, IWritableMount mount) { + MountWrapper(String label, String location, WritableMount mount) { this.label = label; this.location = location; this.mount = mount; diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/SubMount.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/SubMount.java index 1acff8552..f2f644416 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/SubMount.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/SubMount.java @@ -5,18 +5,18 @@ */ package dan200.computercraft.core.filesystem; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.filesystem.Mount; import java.io.IOException; import java.nio.channels.ReadableByteChannel; import java.nio.file.attribute.BasicFileAttributes; import java.util.List; -public class SubMount implements IMount { - private final IMount parent; +public class SubMount implements Mount { + private final Mount parent; private final String subPath; - public SubMount(IMount parent, String subPath) { + public SubMount(Mount parent, String subPath) { this.parent = parent; this.subPath = subPath; } diff --git a/projects/core/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java b/projects/core/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java index ea9f747bc..88101ec25 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java +++ b/projects/core/src/test/java/dan200/computercraft/core/ComputerTestDelegate.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.lua.LuaFunction; @@ -85,7 +85,7 @@ public void before() throws IOException { if (Files.deleteIfExists(REPORT_PATH)) LOG.info("Deleted previous coverage report."); var term = new Terminal(80, 100, true); - IWritableMount mount = new FileMount(TestFiles.get("mount").toFile(), 10_000_000); + WritableMount mount = new FileMount(TestFiles.get("mount").toFile(), 10_000_000); // Remove any existing files List children = new ArrayList<>(); diff --git a/projects/core/src/test/java/dan200/computercraft/core/apis/ObjectWrapper.java b/projects/core/src/test/java/dan200/computercraft/core/apis/ObjectWrapper.java index 818a4349a..8abc39a28 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/apis/ObjectWrapper.java +++ b/projects/core/src/test/java/dan200/computercraft/core/apis/ObjectWrapper.java @@ -50,7 +50,7 @@ public T callOf(Class klass, String name, Object... args) throws LuaExcep } @Override - public long issueMainThreadTask(ILuaTask task) { + public long issueMainThreadTask(LuaTask task) { throw new IllegalStateException("Method should never queue events"); } } diff --git a/projects/core/src/test/java/dan200/computercraft/core/asm/GeneratorTest.java b/projects/core/src/test/java/dan200/computercraft/core/asm/GeneratorTest.java index a7ff518fb..7fba4af6c 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/asm/GeneratorTest.java +++ b/projects/core/src/test/java/dan200/computercraft/core/asm/GeneratorTest.java @@ -240,7 +240,7 @@ public static Matcher> named(String method) { private static final ILuaContext CONTEXT = new ILuaContext() { @Override - public long issueMainThreadTask(ILuaTask task) { + public long issueMainThreadTask(LuaTask task) { return 0; } }; diff --git a/projects/core/src/test/java/dan200/computercraft/core/computer/ComputerBootstrap.java b/projects/core/src/test/java/dan200/computercraft/core/computer/ComputerBootstrap.java index df63f77a0..401b0c9c7 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/computer/ComputerBootstrap.java +++ b/projects/core/src/test/java/dan200/computercraft/core/computer/ComputerBootstrap.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.core.computer; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import dan200.computercraft.api.lua.IArguments; import dan200.computercraft.api.lua.ILuaAPI; import dan200.computercraft.api.lua.LuaException; @@ -45,7 +45,7 @@ public static void run(String program, int maxTimes) { }, maxTimes); } - public static void run(IWritableMount mount, Consumer setup, int maxTicks) { + public static void run(WritableMount mount, Consumer setup, int maxTicks) { CoreConfig.maxMainComputerTime = CoreConfig.maxMainGlobalTime = Integer.MAX_VALUE; var term = new Terminal(51, 19, true); diff --git a/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileMountTest.java b/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileMountTest.java index 7e2a03093..6d9e7cba8 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileMountTest.java +++ b/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileMountTest.java @@ -7,7 +7,7 @@ import com.google.common.io.MoreFiles; import com.google.common.io.RecursiveDeleteOption; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; @@ -39,11 +39,11 @@ private Path createRoot() throws IOException { return path; } - private IWritableMount getExisting(long capacity) throws IOException { + private WritableMount getExisting(long capacity) throws IOException { return new FileMount(createRoot().toFile(), capacity); } - private IWritableMount getNotExisting(long capacity) throws IOException { + private WritableMount getNotExisting(long capacity) throws IOException { return new FileMount(createRoot().resolve("mount").toFile(), capacity); } diff --git a/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileSystemTest.java b/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileSystemTest.java index 45636dc06..16b292dec 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileSystemTest.java +++ b/projects/core/src/test/java/dan200/computercraft/core/filesystem/FileSystemTest.java @@ -6,7 +6,7 @@ package dan200.computercraft.core.filesystem; import com.google.common.io.Files; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.core.TestFiles; import dan200.computercraft.core.apis.ObjectWrapper; @@ -27,7 +27,7 @@ public class FileSystemTest { private static final long CAPACITY = 1000000; private static FileSystem mkFs() throws FileSystemException { - IWritableMount writableMount = new FileMount(ROOT, CAPACITY); + WritableMount writableMount = new FileMount(ROOT, CAPACITY); return new FileSystem("hdd", writableMount); } @@ -65,7 +65,7 @@ public void testWriteTruncates() throws FileSystemException, LuaException, IOExc @Test public void testUnmountCloses() throws FileSystemException { var fs = mkFs(); - IWritableMount mount = new FileMount(new File(ROOT, "child"), CAPACITY); + WritableMount mount = new FileMount(new File(ROOT, "child"), CAPACITY); fs.mountWritable("disk", "disk", mount); var writer = fs.openForWrite("disk/out.txt", false, EncodedWritableHandle::openUtf8); diff --git a/projects/core/src/test/java/dan200/computercraft/core/filesystem/JarMountTest.java b/projects/core/src/test/java/dan200/computercraft/core/filesystem/JarMountTest.java index ca226df4b..d2917c7ea 100644 --- a/projects/core/src/test/java/dan200/computercraft/core/filesystem/JarMountTest.java +++ b/projects/core/src/test/java/dan200/computercraft/core/filesystem/JarMountTest.java @@ -6,7 +6,7 @@ package dan200.computercraft.core.filesystem; import com.google.common.io.ByteStreams; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.filesystem.Mount; import dan200.computercraft.core.TestFiles; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -45,21 +45,21 @@ public static void before() throws IOException { @Test public void mountsDir() throws IOException { - IMount mount = new JarMount(ZIP_FILE, "dir"); + Mount mount = new JarMount(ZIP_FILE, "dir"); assertTrue(mount.isDirectory(""), "Root should be directory"); assertTrue(mount.exists("file.lua"), "File should exist"); } @Test public void mountsFile() throws IOException { - IMount mount = new JarMount(ZIP_FILE, "dir/file.lua"); + Mount mount = new JarMount(ZIP_FILE, "dir/file.lua"); assertTrue(mount.exists(""), "Root should exist"); assertFalse(mount.isDirectory(""), "Root should be a file"); } @Test public void opensFileFromFile() throws IOException { - IMount mount = new JarMount(ZIP_FILE, "dir/file.lua"); + Mount mount = new JarMount(ZIP_FILE, "dir/file.lua"); byte[] contents; try (var stream = mount.openForRead("")) { contents = ByteStreams.toByteArray(Channels.newInputStream(stream)); @@ -70,7 +70,7 @@ public void opensFileFromFile() throws IOException { @Test public void opensFileFromDir() throws IOException { - IMount mount = new JarMount(ZIP_FILE, "dir"); + Mount mount = new JarMount(ZIP_FILE, "dir"); byte[] contents; try (var stream = mount.openForRead("file.lua")) { contents = ByteStreams.toByteArray(Channels.newInputStream(stream)); diff --git a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/apis/BasicApiEnvironment.java b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/apis/BasicApiEnvironment.java index 7793438bb..42dc79ce0 100644 --- a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/apis/BasicApiEnvironment.java +++ b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/apis/BasicApiEnvironment.java @@ -6,7 +6,7 @@ package dan200.computercraft.test.core.apis; import dan200.computercraft.api.peripheral.IPeripheral; -import dan200.computercraft.api.peripheral.IWorkMonitor; +import dan200.computercraft.api.peripheral.WorkMonitor; import dan200.computercraft.core.apis.IAPIEnvironment; import dan200.computercraft.core.computer.ComputerEnvironment; import dan200.computercraft.core.computer.ComputerSide; @@ -42,7 +42,7 @@ public GlobalEnvironment getGlobalEnvironment() { } @Override - public IWorkMonitor getMainThreadMonitor() { + public WorkMonitor getMainThreadMonitor() { throw new IllegalStateException("Main thread monitor not available"); } diff --git a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/computer/BasicEnvironment.java b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/computer/BasicEnvironment.java index 99fd46358..e60f3b342 100644 --- a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/computer/BasicEnvironment.java +++ b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/computer/BasicEnvironment.java @@ -5,8 +5,8 @@ */ package dan200.computercraft.test.core.computer; -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.core.ComputerContext; import dan200.computercraft.core.computer.ComputerEnvironment; import dan200.computercraft.core.computer.GlobalEnvironment; @@ -29,18 +29,18 @@ * will only run a single computer. */ public class BasicEnvironment implements ComputerEnvironment, GlobalEnvironment, MetricsObserver { - private final IWritableMount mount; + private final WritableMount mount; public BasicEnvironment() { this(new MemoryMount()); } - public BasicEnvironment(IWritableMount mount) { + public BasicEnvironment(WritableMount mount) { this.mount = mount; } @Override - public IWritableMount createRootMount() { + public WritableMount createRootMount() { return mount; } @@ -70,7 +70,7 @@ public String getUserAgent() { } @Override - public IMount createResourceMount(String domain, String subPath) { + public Mount createResourceMount(String domain, String subPath) { return createMount(ComputerContext.class, "data/" + domain + "/" + subPath, "main"); } @@ -79,7 +79,7 @@ public InputStream createResourceFile(String domain, String subPath) { return ComputerContext.class.getClassLoader().getResourceAsStream("data/" + domain + "/" + subPath); } - public static IMount createMount(Class klass, String path, String fallback) { + public static Mount createMount(Class klass, String path, String fallback) { var file = getContainingFile(klass); if (file.isFile()) { diff --git a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/filesystem/MemoryMount.java b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/filesystem/MemoryMount.java index f34192cdc..f7b7e8feb 100644 --- a/projects/core/src/testFixtures/java/dan200/computercraft/test/core/filesystem/MemoryMount.java +++ b/projects/core/src/testFixtures/java/dan200/computercraft/test/core/filesystem/MemoryMount.java @@ -6,7 +6,7 @@ package dan200.computercraft.test.core.filesystem; import dan200.computercraft.api.filesystem.FileOperationException; -import dan200.computercraft.api.filesystem.IWritableMount; +import dan200.computercraft.api.filesystem.WritableMount; import dan200.computercraft.core.apis.handles.ArrayByteChannel; import java.io.ByteArrayOutputStream; @@ -21,7 +21,7 @@ /** * In-memory file mounts. */ -public class MemoryMount implements IWritableMount { +public class MemoryMount implements WritableMount { private final Map files = new HashMap<>(); private final Set directories = new HashSet<>(); diff --git a/projects/fabric-api/build.gradle.kts b/projects/fabric-api/build.gradle.kts index ffacd9aa4..8618e7b8b 100644 --- a/projects/fabric-api/build.gradle.kts +++ b/projects/fabric-api/build.gradle.kts @@ -1,5 +1,3 @@ -import cc.tweaked.gradle.mavenDependencies - plugins { id("cc-tweaked.fabric") id("cc-tweaked.publishing") @@ -15,7 +13,6 @@ cct.inlineProject(":common-api") dependencies { api(project(":core-api")) - compileOnly(project(":forge-stubs")) } tasks.jar { @@ -23,24 +20,5 @@ tasks.jar { attributes["Fabric-Loom-Remap"] = "true" } - from(project(":core-api").sourceSets.main.get().output) // TODO(1.19.3): Remove when we've fixed GenericSource from("src/main/modJson") // TODO: Remove once Loom 1.1 is out. } - -// TODO(1.19.3): Remove when GenericSource no longer uses ResourceLocation. This forces us to bundle the core API with -// the Fabric API, in order to remap those classes. - -tasks.sourcesJar { - from(project(":core-api").sourceSets.main.get().allJava) -} - -tasks.withType(GenerateModuleMetadata::class).configureEach { isEnabled = false } -publishing { - publications { - named("maven", MavenPublication::class) { - mavenDependencies { - exclude(dependencies.create("cc.tweaked:")) - } - } - } -} diff --git a/projects/fabric-api/src/main/java/dan200/computercraft/api/node/wired/WiredElementLookup.java b/projects/fabric-api/src/main/java/dan200/computercraft/api/node/wired/WiredElementLookup.java index 4e25c6fbe..597165b51 100644 --- a/projects/fabric-api/src/main/java/dan200/computercraft/api/node/wired/WiredElementLookup.java +++ b/projects/fabric-api/src/main/java/dan200/computercraft/api/node/wired/WiredElementLookup.java @@ -6,24 +6,24 @@ package dan200.computercraft.api.node.wired; import dan200.computercraft.api.ComputerCraftAPI; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; /** - * {@linkplain BlockApiLookup Block API lookup} for {@link IWiredElement}s. This should be used to query wired elements + * {@linkplain BlockApiLookup Block API lookup} for {@link WiredElement}s. This should be used to query wired elements * from a block. */ public final class WiredElementLookup { public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "wired_node"); - private static final BlockApiLookup lookup = BlockApiLookup.get(ID, IWiredElement.class, Direction.class); + private static final BlockApiLookup lookup = BlockApiLookup.get(ID, WiredElement.class, Direction.class); private WiredElementLookup() { } - public static BlockApiLookup get() { + public static BlockApiLookup get() { return lookup; } } diff --git a/projects/fabric/build.gradle.kts b/projects/fabric/build.gradle.kts index 37e11fb93..58191acbc 100644 --- a/projects/fabric/build.gradle.kts +++ b/projects/fabric/build.gradle.kts @@ -64,8 +64,6 @@ dependencies { runtimeOnly(libs.cobalt) runtimeOnly(libs.netty.http) - compileOnly(project(":forge-stubs")) - annotationProcessorEverywhere(libs.autoService) testModImplementation(testFixtures(project(":core"))) diff --git a/projects/fabric/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java b/projects/fabric/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java index cc5fdc8e4..2daaf898a 100644 --- a/projects/fabric/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java +++ b/projects/fabric/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java @@ -8,14 +8,14 @@ import com.google.auto.service.AutoService; import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.detail.DetailRegistry; -import dan200.computercraft.api.filesystem.IMount; +import dan200.computercraft.api.filesystem.Mount; import dan200.computercraft.impl.detail.DetailRegistryImpl; -import dan200.computercraft.shared.ComputerCraft; import dan200.computercraft.shared.computer.core.ResourceMount; import dan200.computercraft.shared.details.FluidDetails; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.storage.StorageView; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.server.MinecraftServer; import javax.annotation.Nullable; @@ -35,9 +35,8 @@ public String getInstalledVersion() { @Nullable @Override - public IMount createResourceMount(String domain, String subPath) { - if (ComputerCraft.server == null) return null; - var mount = ResourceMount.get(domain, subPath, ComputerCraft.server.getResourceManager()); + public Mount createResourceMount(MinecraftServer server, String domain, String subPath) { + var mount = ResourceMount.get(domain, subPath, server.getResourceManager()); return mount.exists("") ? mount : null; } diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java b/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java index b8dcb9d26..10118c22e 100644 --- a/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java +++ b/projects/fabric/src/main/java/dan200/computercraft/shared/ComputerCraft.java @@ -33,7 +33,6 @@ import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.ResourceManager; @@ -43,13 +42,10 @@ import net.minecraftforge.api.fml.event.config.ModConfigEvents; import net.minecraftforge.fml.config.ModConfig; -import javax.annotation.Nullable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; public class ComputerCraft { - public static @Nullable MinecraftServer server; - public static void init() { NetworkHandler.init(); FabricRegistryBuilder.createSimple(TurtleUpgradeSerialiser.class, TurtleUpgradeSerialiser.REGISTRY_ID.location()).buildAndRegister(); @@ -82,14 +78,8 @@ public static void init() { CommandRegistrationCallback.EVENT.register((dispatcher, context, environment) -> CommandComputerCraft.register(dispatcher)); // Register hooks - ServerLifecycleEvents.SERVER_STARTING.register(s -> { - server = s; - CommonHooks.onServerStarting(s); - }); - ServerLifecycleEvents.SERVER_STOPPED.register(s -> { - server = s; - CommonHooks.onServerStopped(); - }); + ServerLifecycleEvents.SERVER_STARTING.register(CommonHooks::onServerStarting); + ServerLifecycleEvents.SERVER_STOPPED.register(s -> CommonHooks.onServerStopped()); ServerLifecycleEvents.SYNC_DATA_PACK_CONTENTS.register((player, joined) -> PlatformHelper.get().sendToPlayer(new UpgradesLoadedMessage(), player)); ServerTickEvents.START_SERVER_TICK.register(CommonHooks::onServerTickStart); diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/details/FluidDetails.java b/projects/fabric/src/main/java/dan200/computercraft/shared/details/FluidDetails.java index 054cb2dd4..3afecec1e 100644 --- a/projects/fabric/src/main/java/dan200/computercraft/shared/details/FluidDetails.java +++ b/projects/fabric/src/main/java/dan200/computercraft/shared/details/FluidDetails.java @@ -5,8 +5,8 @@ */ package dan200.computercraft.shared.details; +import dan200.computercraft.api.detail.DetailProvider; import dan200.computercraft.api.detail.FabricDetailRegistries; -import dan200.computercraft.api.detail.IDetailProvider; import dan200.computercraft.shared.platform.Registries; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.storage.StorageView; @@ -14,7 +14,7 @@ import java.util.Map; /** - * {@link IDetailProvider} support for fluids. + * {@link DetailProvider} support for fluids. * * @see FabricDetailRegistries#FLUID_VARIANT */ diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/projects/fabric/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index 2c315a06c..7031718fb 100644 --- a/projects/fabric/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/projects/fabric/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -19,7 +19,6 @@ import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage; import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant; import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; @@ -42,8 +41,8 @@ public PeripheralType getType() { } @Override - public ResourceLocation id() { - return new ResourceLocation(ComputerCraftAPI.MOD_ID, "inventory"); + public String id() { + return ComputerCraftAPI.MOD_ID + ":inventory"; } @LuaFunction(mainThread = true) diff --git a/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java b/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java index 7d6f9958f..891b7924b 100644 --- a/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java +++ b/projects/fabric/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java @@ -9,7 +9,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.brigadier.arguments.ArgumentType; import dan200.computercraft.api.ComputerCraftAPI; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.node.wired.WiredElementLookup; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.PeripheralLookup; @@ -192,7 +192,7 @@ public ComponentAccess createPeripheralAccess(Consumer i } @Override - public ComponentAccess createWiredElementAccess(Consumer invalidate) { + public ComponentAccess createWiredElementAccess(Consumer invalidate) { return new ComponentAccessImpl<>(WiredElementLookup.get()); } diff --git a/projects/forge-api/src/main/java/dan200/computercraft/api/ForgeComputerCraftAPI.java b/projects/forge-api/src/main/java/dan200/computercraft/api/ForgeComputerCraftAPI.java index b3890c94e..3b1cf5671 100644 --- a/projects/forge-api/src/main/java/dan200/computercraft/api/ForgeComputerCraftAPI.java +++ b/projects/forge-api/src/main/java/dan200/computercraft/api/ForgeComputerCraftAPI.java @@ -6,7 +6,7 @@ package dan200.computercraft.api; import dan200.computercraft.api.lua.GenericSource; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheralProvider; import dan200.computercraft.impl.ComputerCraftAPIForgeService; @@ -20,8 +20,6 @@ * The forge-specific entrypoint for ComputerCraft's API. */ public final class ForgeComputerCraftAPI { - // TODO(1.19.3): Rename me to ComputerCraftAPIForge - private ForgeComputerCraftAPI() { } @@ -53,9 +51,9 @@ public static void registerGenericCapability(Capability capability) { * @param pos The position the block exists in * @param side The side to extract the network element from * @return The element's node - * @see IWiredElement#getNode() + * @see WiredElement#getNode() */ - public static LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { + public static LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { return getInstance().getWiredElementAt(world, pos, side); } diff --git a/projects/common-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheralProvider.java b/projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheralProvider.java similarity index 100% rename from projects/common-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheralProvider.java rename to projects/forge-api/src/main/java/dan200/computercraft/api/peripheral/IPeripheralProvider.java diff --git a/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java b/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java deleted file mode 100644 index 3f3f74a88..000000000 --- a/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the public ComputerCraft API - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only. - * For help using the API, and posting your mods, visit the forums at computercraft.info. - */ -package dan200.computercraft.api.turtle.event; - -import dan200.computercraft.api.turtle.ITurtleAccess; -import net.minecraftforge.eventbus.api.Event; - -import java.util.Objects; - -/** - * A base class for all events concerning a turtle. This will only ever constructed and fired on the server side, - * so sever specific methods on {@link ITurtleAccess} are safe to use. - *

- * You should generally not need to subscribe to this event, preferring one of the more specific classes. - * - * @deprecated No longer needed, see {@link TurtleRefuelEvent}. - */ -@Deprecated(forRemoval = true) -public abstract class TurtleEvent extends Event { - private final ITurtleAccess turtle; - - protected TurtleEvent(ITurtleAccess turtle) { - Objects.requireNonNull(turtle, "turtle cannot be null"); - this.turtle = turtle; - } - - /** - * Get the turtle which is performing this action. - * - * @return The access for this turtle. - */ - public ITurtleAccess getTurtle() { - return turtle; - } -} diff --git a/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java b/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java deleted file mode 100644 index dfca12b1e..000000000 --- a/projects/forge-api/src/main/java/dan200/computercraft/api/turtle/event/TurtleRefuelEvent.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the public ComputerCraft API - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. This API may be redistributed unmodified and in full only. - * For help using the API, and posting your mods, visit the forums at computercraft.info. - */ -package dan200.computercraft.api.turtle.event; - -import dan200.computercraft.api.turtle.ITurtleAccess; -import dan200.computercraft.api.turtle.TurtleRefuelHandler; -import net.minecraft.world.item.ItemStack; - -import javax.annotation.Nullable; -import java.util.Objects; - -/** - * Fired when a turtle attempts to refuel from an item. - *

- * One may use {@link #setHandler(Handler)} to register a custom fuel provider for a given item. - * - * @deprecated Use {@link TurtleRefuelHandler} instead. - */ -@Deprecated(forRemoval = true) -public class TurtleRefuelEvent extends TurtleEvent { - private final ItemStack stack; - private @Nullable Handler handler; - - public TurtleRefuelEvent(ITurtleAccess turtle, ItemStack stack) { - super(turtle); - - Objects.requireNonNull(turtle, "turtle cannot be null"); - this.stack = stack; - } - - /** - * Get the stack we are attempting to refuel from. - *

- * Do not modify the returned stack - all modifications should be done within the {@link Handler}. - * - * @return The stack to refuel from. - */ - public ItemStack getStack() { - return stack; - } - - /** - * Get the refuel handler for this stack. - * - * @return The refuel handler, or {@code null} if none has currently been set. - * @see #setHandler(Handler) - */ - @Nullable - public Handler getHandler() { - return handler; - } - - /** - * Set the refuel handler for this stack. - *

- * You should call this if you can actually refuel from this item, and ideally only if there are no existing - * handlers. - * - * @param handler The new refuel handler. - * @see #getHandler() - */ - public void setHandler(@Nullable Handler handler) { - this.handler = handler; - } - - /** - * Handles refuelling a turtle from a specific item. - */ - @FunctionalInterface - public interface Handler { - /** - * Refuel a turtle using an item. - * - * @param turtle The turtle to refuel. - * @param stack The stack to refuel with. - * @param slot The slot the stack resides within. This may be used to modify the inventory afterwards. - * @param limit The maximum number of refuel operations to perform. This will often correspond to the number of - * items to consume. - * @return The amount of fuel gained. - */ - int refuel(ITurtleAccess turtle, ItemStack stack, int slot, int limit); - } -} diff --git a/projects/forge-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIForgeService.java b/projects/forge-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIForgeService.java index d625b21c4..d760ed9dd 100644 --- a/projects/forge-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIForgeService.java +++ b/projects/forge-api/src/main/java/dan200/computercraft/impl/ComputerCraftAPIForgeService.java @@ -7,8 +7,13 @@ import dan200.computercraft.api.ForgeComputerCraftAPI; import dan200.computercraft.api.detail.DetailRegistry; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.peripheral.IPeripheralProvider; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.ApiStatus; @@ -25,11 +30,11 @@ static ComputerCraftAPIForgeService get() { return (ComputerCraftAPIForgeService) ComputerCraftAPIService.get(); } - @Override void registerPeripheralProvider(IPeripheralProvider provider); - @Override void registerGenericCapability(Capability capability); + LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side); + DetailRegistry getFluidStackDetailRegistry(); } diff --git a/projects/forge-stubs/build.gradle.kts b/projects/forge-stubs/build.gradle.kts deleted file mode 100644 index 7dd63a3b1..000000000 --- a/projects/forge-stubs/build.gradle.kts +++ /dev/null @@ -1,8 +0,0 @@ -plugins { - id("cc-tweaked.java-convention") -} - -// Skip checkstyle here, it's going to be deleted soon anyway! -tasks.checkstyleMain { - enabled = false -} diff --git a/projects/forge-stubs/src/main/java/net/minecraftforge/common/capabilities/Capability.java b/projects/forge-stubs/src/main/java/net/minecraftforge/common/capabilities/Capability.java deleted file mode 100644 index 9559a4838..000000000 --- a/projects/forge-stubs/src/main/java/net/minecraftforge/common/capabilities/Capability.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraftforge.common.capabilities; - -@Deprecated -public class Capability { - private Capability() { - } -} diff --git a/projects/forge-stubs/src/main/java/net/minecraftforge/common/util/LazyOptional.java b/projects/forge-stubs/src/main/java/net/minecraftforge/common/util/LazyOptional.java deleted file mode 100644 index 4d12aa41d..000000000 --- a/projects/forge-stubs/src/main/java/net/minecraftforge/common/util/LazyOptional.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraftforge.common.util; - -public final class LazyOptional { - private LazyOptional() { - } - - public static LazyOptional empty() { - throw new UnsupportedOperationException(); - } -} diff --git a/projects/forge-stubs/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java b/projects/forge-stubs/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java deleted file mode 100644 index ff7a77578..000000000 --- a/projects/forge-stubs/src/main/java/net/minecraftforge/items/IItemHandlerModifiable.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraftforge.items; - -@Deprecated -public interface IItemHandlerModifiable { -} diff --git a/projects/forge-stubs/src/main/java/net/minecraftforge/registries/IForgeRegistry.java b/projects/forge-stubs/src/main/java/net/minecraftforge/registries/IForgeRegistry.java deleted file mode 100644 index 6f8b920c0..000000000 --- a/projects/forge-stubs/src/main/java/net/minecraftforge/registries/IForgeRegistry.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraftforge.registries; - -@Deprecated -public interface IForgeRegistry { -} diff --git a/projects/forge-stubs/src/main/java/net/minecraftforge/registries/RegistryManager.java b/projects/forge-stubs/src/main/java/net/minecraftforge/registries/RegistryManager.java deleted file mode 100644 index 0c26db35a..000000000 --- a/projects/forge-stubs/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraftforge.registries; - -@Deprecated -public class RegistryManager { - public static final RegistryManager ACTIVE = new RegistryManager(); - - private RegistryManager() { - } - - public IForgeRegistry getRegistry(Object object) { - throw new UnsupportedOperationException(); - } -} diff --git a/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java b/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java index 6cfdebb44..5a48557a8 100644 --- a/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/projects/forge/src/main/java/dan200/computercraft/ComputerCraft.java @@ -8,12 +8,10 @@ import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ForgeComputerCraftAPI; import dan200.computercraft.api.detail.ForgeDetailRegistries; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.pocket.PocketUpgradeSerialiser; import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser; -import dan200.computercraft.api.turtle.event.TurtleRefuelEvent; -import dan200.computercraft.impl.TurtleRefuelHandlers; import dan200.computercraft.shared.ModRegistry; import dan200.computercraft.shared.config.ConfigSpec; import dan200.computercraft.shared.details.FluidData; @@ -21,7 +19,6 @@ import dan200.computercraft.shared.peripheral.generic.methods.FluidMethods; import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods; import dan200.computercraft.shared.platform.NetworkHandler; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -33,8 +30,6 @@ import net.minecraftforge.registries.NewRegistryEvent; import net.minecraftforge.registries.RegistryBuilder; -import java.util.OptionalInt; - @Mod(ComputerCraftAPI.MOD_ID) @Mod.EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public final class ComputerCraft { @@ -44,15 +39,6 @@ public ComputerCraft() { ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ConfigSpec.serverSpec); ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigSpec.clientSpec); - // Register a fallback handler for the turtle refuel event. - TurtleRefuelHandlers.register((turtle, stack, slot, limit) -> { - @SuppressWarnings("removal") var event = new TurtleRefuelEvent(turtle, stack); - MinecraftForge.EVENT_BUS.post(event); - if (event.getHandler() == null) return OptionalInt.empty(); - if (limit == 0) return OptionalInt.of(0); - return OptionalInt.of(event.getHandler().refuel(turtle, stack, slot, limit)); - }); - NetworkHandler.setup(); } @@ -69,7 +55,7 @@ public static void registerRegistries(NewRegistryEvent event) { @SubscribeEvent public static void registerCapabilities(RegisterCapabilitiesEvent event) { - event.register(IWiredElement.class); + event.register(WiredElement.class); event.register(IPeripheral.class); } diff --git a/projects/forge/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java b/projects/forge/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java index 1baaed4a8..ccebb890e 100644 --- a/projects/forge/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java +++ b/projects/forge/src/main/java/dan200/computercraft/impl/ComputerCraftAPIImpl.java @@ -8,9 +8,8 @@ import com.google.auto.service.AutoService; import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.detail.DetailRegistry; -import dan200.computercraft.api.detail.IDetailProvider; -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.IPeripheralProvider; import dan200.computercraft.impl.detail.DetailRegistryImpl; import dan200.computercraft.shared.computer.core.ResourceMount; @@ -18,6 +17,7 @@ import dan200.computercraft.shared.peripheral.generic.GenericPeripheralProvider; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.BlockGetter; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; @@ -44,7 +44,7 @@ public String getInstalledVersion() { } @Override - public @Nullable IMount createResourceMount(String domain, String subPath) { + public @Nullable Mount createResourceMount(MinecraftServer server, String domain, String subPath) { var manager = ServerLifecycleHooks.getCurrentServer().getResourceManager(); var mount = ResourceMount.get(domain, subPath, manager); return mount.exists("") ? mount : null; @@ -61,18 +61,7 @@ public void registerGenericCapability(Capability capability) { } @Override - @Deprecated - @SuppressWarnings("unchecked") - public void registerDetailProvider(Class type, IDetailProvider provider) { - if (type == FluidStack.class) { - fluidStackDetails.addProvider((IDetailProvider) provider); - } else { - super.registerDetailProvider(type, provider); - } - } - - @Override - public LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { + public LazyOptional getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) { var tile = world.getBlockEntity(pos); return tile == null ? LazyOptional.empty() : tile.getCapability(CAPABILITY_WIRED_ELEMENT, side); } diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/Capabilities.java b/projects/forge/src/main/java/dan200/computercraft/shared/Capabilities.java index 440ee44b7..7bc374604 100644 --- a/projects/forge/src/main/java/dan200/computercraft/shared/Capabilities.java +++ b/projects/forge/src/main/java/dan200/computercraft/shared/Capabilities.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.shared; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.peripheral.IPeripheral; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; @@ -15,7 +15,7 @@ public final class Capabilities { public static final Capability CAPABILITY_PERIPHERAL = CapabilityManager.get(new CapabilityToken<>() { }); - public static final Capability CAPABILITY_WIRED_ELEMENT = CapabilityManager.get(new CapabilityToken<>() { + public static final Capability CAPABILITY_WIRED_ELEMENT = CapabilityManager.get(new CapabilityToken<>() { }); private Capabilities() { diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java index cd2e797ff..e13d8f2ff 100644 --- a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java +++ b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/EnergyMethods.java @@ -9,7 +9,6 @@ import dan200.computercraft.api.lua.LuaFunction; import dan200.computercraft.api.peripheral.GenericPeripheral; import dan200.computercraft.api.peripheral.PeripheralType; -import net.minecraft.resources.ResourceLocation; import net.minecraftforge.energy.IEnergyStorage; /** @@ -32,8 +31,8 @@ public PeripheralType getType() { } @Override - public ResourceLocation id() { - return new ResourceLocation(ComputerCraftAPI.MOD_ID, "energy"); + public String id() { + return ComputerCraftAPI.MOD_ID + ":energy"; } /** diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java index f80aaad27..62c4d79d2 100644 --- a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java +++ b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/FluidMethods.java @@ -13,7 +13,6 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.PeripheralType; import dan200.computercraft.shared.platform.Registries; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -40,8 +39,8 @@ public PeripheralType getType() { } @Override - public ResourceLocation id() { - return new ResourceLocation(ComputerCraftAPI.MOD_ID, "fluid"); + public String id() { + return ComputerCraftAPI.MOD_ID + ":fluid"; } /** diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java index 3a494f1b6..ade31a94e 100644 --- a/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java +++ b/projects/forge/src/main/java/dan200/computercraft/shared/peripheral/generic/methods/InventoryMethods.java @@ -14,7 +14,6 @@ import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.PeripheralType; import dan200.computercraft.shared.platform.ForgeContainerTransfer; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.Container; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.common.capabilities.ForgeCapabilities; @@ -42,8 +41,8 @@ public PeripheralType getType() { } @Override - public ResourceLocation id() { - return new ResourceLocation(ComputerCraftAPI.MOD_ID, "inventory"); + public String id() { + return ComputerCraftAPI.MOD_ID + ":inventory"; } /** diff --git a/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java b/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java index c4b4a0065..35dffa5b4 100644 --- a/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java +++ b/projects/forge/src/main/java/dan200/computercraft/shared/platform/PlatformHelperImpl.java @@ -9,7 +9,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.brigadier.arguments.ArgumentType; import dan200.computercraft.api.ComputerCraftAPI; -import dan200.computercraft.api.network.wired.IWiredElement; +import dan200.computercraft.api.network.wired.WiredElement; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.impl.Peripherals; import dan200.computercraft.shared.Capabilities; @@ -62,7 +62,6 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; import net.minecraftforge.network.NetworkHooks; @@ -173,7 +172,7 @@ public ComponentAccess createPeripheralAccess(Consumer i } @Override - public ComponentAccess createWiredElementAccess(Consumer invalidate) { + public ComponentAccess createWiredElementAccess(Consumer invalidate) { return new CapabilityAccess<>(Capabilities.CAPABILITY_WIRED_ELEMENT, invalidate); } @@ -211,12 +210,6 @@ public ContainerTransfer getContainer(ServerLevel level, BlockPos pos, Direction return entity == null ? null : new ForgeContainerTransfer(new InvWrapper(entity)); } - @Override - @Deprecated(forRemoval = true) - public IItemHandlerModifiable wrapContainerToItemHandler(Container container) { - return new InvWrapper(container); - } - @Nullable @Override public CompoundTag getShareTag(ItemStack item) { diff --git a/projects/mc-stubs/build.gradle.kts b/projects/mc-stubs/build.gradle.kts deleted file mode 100644 index 7dd63a3b1..000000000 --- a/projects/mc-stubs/build.gradle.kts +++ /dev/null @@ -1,8 +0,0 @@ -plugins { - id("cc-tweaked.java-convention") -} - -// Skip checkstyle here, it's going to be deleted soon anyway! -tasks.checkstyleMain { - enabled = false -} diff --git a/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java b/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java deleted file mode 100644 index b7697ab2c..000000000 --- a/projects/mc-stubs/src/main/java/net/minecraft/resources/ResourceLocation.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file is part of ComputerCraft - http://www.computercraft.info - * Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission. - * Send enquiries to dratcliffe@gmail.com - */ -package net.minecraft.resources; - -/** - * Placeholder class so we can preserve API compatibility for this release. - */ -public final class ResourceLocation { - private ResourceLocation() { - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 439e0d31c..4128e2835 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,8 +51,6 @@ rootProject.name = "cc-tweaked-$mcVersion" include(":core-api") include(":core") -include(":mc-stubs") -include(":forge-stubs") include(":common-api") include(":common") include(":fabric-api")