mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-30 05:12:58 +00:00
Initial pass of the API breaking changes for 1.19.3 (#1232)
- Remove deprecated API members in prep for 1.19.3. This allows us to remove the mc-stubs and forge-stubs projects. - Make several methods take a MinecraftServer instead of a Level (or nothing at all). - Remove I prefixes from a whole bunch of interfaces, making things a little more consistent with Java conventions. This avoids touching the "main" interfaces people consume for now. I want to do that another Minecraft version, to avoid making the update too painful. - Remove IFileSystem and associated getters. This has never worked very well and I don't think has got much (any?) usage.
This commit is contained in:
@@ -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 final class ComputerCraftAPI {
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 final class ComputerCraftAPI {
|
||||
* 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 final class ComputerCraftAPI {
|
||||
* "/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 final class ComputerCraftAPI {
|
||||
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 final class ComputerCraftAPI {
|
||||
* @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 final class ComputerCraftAPI {
|
||||
* 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.
|
||||
* <p>
|
||||
* 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 <T> 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 <T> void registerDetailProvider(Class<T> type, IDetailProvider<T> provider) {
|
||||
getInstance().registerDetailProvider(type, provider);
|
||||
public static void registerAPIFactory(ILuaAPIFactory factory) {
|
||||
getInstance().registerAPIFactory(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,27 +177,19 @@ public final class ComputerCraftAPI {
|
||||
*
|
||||
* @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<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
|
||||
return getInstance().getWiredElementAt(world, pos, side);
|
||||
}
|
||||
|
||||
public static void registerRefuelHandler(TurtleRefuelHandler handler) {
|
||||
getInstance().registerRefuelHandler(handler);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.Objects;
|
||||
*
|
||||
* @param <T> The type the stack's item must have.
|
||||
*/
|
||||
public abstract class BasicItemDetailProvider<T> implements IDetailProvider<ItemStack> {
|
||||
public abstract class BasicItemDetailProvider<T> implements DetailProvider<ItemStack> {
|
||||
private final Class<T> itemType;
|
||||
private final @Nullable String namespace;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Map;
|
||||
* @see DetailRegistry
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IDetailProvider<T> {
|
||||
public interface DetailProvider<T> {
|
||||
/**
|
||||
* 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
|
||||
@@ -25,9 +25,9 @@ public interface DetailRegistry<T> {
|
||||
* Registers a detail provider.
|
||||
*
|
||||
* @param provider The detail provider to register.
|
||||
* @see IDetailProvider
|
||||
* @see DetailProvider
|
||||
*/
|
||||
void addProvider(IDetailProvider<T> provider);
|
||||
void addProvider(DetailProvider<T> provider);
|
||||
|
||||
/**
|
||||
* Compute basic details about an object. This is cheaper than computing all details operation, and so is suitable
|
||||
|
||||
@@ -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 @@ import javax.annotation.Nullable;
|
||||
* Represents an item that can be placed in a disk drive and used by a Computer.
|
||||
* <p>
|
||||
* 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 @@ public interface IMedia {
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* 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);
|
||||
@@ -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 @@ package dan200.computercraft.api.network;
|
||||
* @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
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ package dan200.computercraft.api.network;
|
||||
* 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);
|
||||
}
|
||||
@@ -10,9 +10,9 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@@ -10,9 +10,9 @@ import net.minecraft.world.phys.Vec3;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -11,21 +11,21 @@ import dan200.computercraft.api.ComputerCraftAPI;
|
||||
/**
|
||||
* An object which may be part of a wired network.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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) {
|
||||
}
|
||||
}
|
||||
@@ -10,20 +10,20 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
@@ -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<String, IPeripheral> peripherals);
|
||||
void updatePeripherals(WiredNode node, Map<String, IPeripheral> peripherals);
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import java.util.Map;
|
||||
/**
|
||||
* 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.
|
||||
@@ -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.
|
||||
* <p>
|
||||
* 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 @@ import java.util.Map;
|
||||
* 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 @@ public interface IWiredNode extends IPacketNetwork {
|
||||
* @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 @@ public interface IWiredNode extends IPacketNetwork {
|
||||
* @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 @@ public interface IWiredNode extends IPacketNetwork {
|
||||
* 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<String, IPeripheral> peripherals) {
|
||||
getNetwork().updatePeripherals(this, peripherals);
|
||||
@@ -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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
@@ -23,5 +23,5 @@ public interface IWiredSender extends IPacketSender {
|
||||
*
|
||||
* @return The node for this element.
|
||||
*/
|
||||
IWiredNode getNode();
|
||||
WiredNode getNode();
|
||||
}
|
||||
@@ -1,37 +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.peripheral;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
|
||||
/**
|
||||
* This interface is used to create peripheral implementations for blocks.
|
||||
* <p>
|
||||
* If you have a {@link BlockEntity} which acts as a peripheral, you may alternatively expose the {@link IPeripheral}
|
||||
* capability.
|
||||
* <p>
|
||||
* {@code dan200.computercraft.api.ForgeComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)} should be used
|
||||
* to register a peripheral provider.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IPeripheralProvider {
|
||||
// TODO(1.19.3): Move to Forge and fix link above.
|
||||
|
||||
/**
|
||||
* Produce an peripheral implementation from a block location.
|
||||
*
|
||||
* @param world The world the block is in.
|
||||
* @param pos The position the block is at.
|
||||
* @param side The side to get the peripheral from.
|
||||
* @return A peripheral, or {@link LazyOptional#empty()} if there is not a peripheral here you'd like to handle.
|
||||
*/
|
||||
LazyOptional<IPeripheral> getPeripheral(Level world, BlockPos pos, Direction side);
|
||||
}
|
||||
@@ -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 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade {
|
||||
}
|
||||
|
||||
protected AbstractPocketUpgrade(ResourceLocation id, ItemStack stack) {
|
||||
this(id, IUpgradeBase.getDefaultAdjective(id), stack);
|
||||
this(id, UpgradeBase.getDefaultAdjective(id), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 @@ import javax.annotation.Nullable;
|
||||
*
|
||||
* @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.
|
||||
* <p>
|
||||
|
||||
@@ -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.ResourceKey;
|
||||
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<T extends IPocketUpgrade> extends Upgra
|
||||
*/
|
||||
ResourceKey<Registry<PocketUpgradeSerialiser<?>>> 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<PocketUpgradeSerialiser<?>> 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 @@ public interface PocketUpgradeSerialiser<T extends IPocketUpgrade> extends Upgra
|
||||
* 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()} <strong>MUST</strong> equal the provided item.
|
||||
* {@link UpgradeBase#getCraftingItem()} <strong>MUST</strong> equal the provided item.
|
||||
* @param <T> The type of the generated upgrade.
|
||||
* @return The serialiser for this upgrade.
|
||||
* @see #simple(Function) For upgrades whose crafting stack should not vary.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade {
|
||||
}
|
||||
|
||||
protected AbstractTurtleUpgrade(ResourceLocation id, TurtleUpgradeType type, ItemStack stack) {
|
||||
this(id, type, IUpgradeBase.getDefaultAdjective(id), stack);
|
||||
this(id, type, UpgradeBase.getDefaultAdjective(id), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||
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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
@@ -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}.
|
||||
* <p>
|
||||
* 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
|
||||
|
||||
@@ -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 @@ import javax.annotation.Nullable;
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
|
||||
@@ -7,12 +7,12 @@ package dan200.computercraft.api.turtle;
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
@@ -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
|
||||
@@ -12,7 +12,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
@@ -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.resources.ResourceLocation;
|
||||
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<T extends ITurtleUpgrade> extends Upgra
|
||||
*/
|
||||
ResourceKey<Registry<TurtleUpgradeSerialiser<?>>> 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<TurtleUpgradeSerialiser<?>> 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 @@ public interface TurtleUpgradeSerialiser<T extends ITurtleUpgrade> extends Upgra
|
||||
* 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()} <strong>MUST</strong> equal the provided item.
|
||||
* {@link UpgradeBase#getCraftingItem()} <strong>MUST</strong> equal the provided item.
|
||||
* @param <T> The type of the generated upgrade.
|
||||
* @return The serialiser for this upgrade.
|
||||
* @see #simple(Function) For upgrades whose crafting stack should not vary.
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* 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".
|
||||
@@ -37,7 +37,7 @@ import java.util.function.Function;
|
||||
* @param <T> The base class of upgrades.
|
||||
* @param <R> The upgrade serialiser to register for.
|
||||
*/
|
||||
public abstract class UpgradeDataProvider<T extends IUpgradeBase, R extends UpgradeSerialiser<? extends T>> implements DataProvider {
|
||||
public abstract class UpgradeDataProvider<T extends UpgradeBase, R extends UpgradeSerialiser<? extends T>> implements DataProvider {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final DataGenerator generator;
|
||||
|
||||
@@ -22,13 +22,13 @@ import net.minecraft.resources.ResourceLocation;
|
||||
* @see TurtleUpgradeSerialiser
|
||||
* @see PocketUpgradeSerialiser
|
||||
*/
|
||||
public interface UpgradeSerialiser<T extends IUpgradeBase> {
|
||||
public interface UpgradeSerialiser<T extends UpgradeBase> {
|
||||
/**
|
||||
* 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<T extends IUpgradeBase> {
|
||||
*
|
||||
* @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);
|
||||
|
||||
|
||||
@@ -8,25 +8,21 @@ package dan200.computercraft.impl;
|
||||
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 @@ public interface ComputerCraftAPIService {
|
||||
|
||||
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
|
||||
<T> void registerDetailProvider(Class<T> type, IDetailProvider<T> provider);
|
||||
|
||||
IWiredNode createWiredNodeForElement(IWiredElement element);
|
||||
|
||||
default LazyOptional<IWiredElement> getWiredElementAt(BlockGetter world, BlockPos pos, Direction side) {
|
||||
throw new UnsupportedOperationException("Can only call getWiredElementAt on Forge");
|
||||
}
|
||||
WiredNode createWiredNodeForElement(WiredElement element);
|
||||
|
||||
void registerRefuelHandler(TurtleRefuelHandler handler);
|
||||
|
||||
|
||||
@@ -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 @@ import java.util.function.BiFunction;
|
||||
* @param <T> The upgrade that this class can serialise and deserialise.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public abstract class SerialiserWithCraftingItem<T extends IUpgradeBase> implements UpgradeSerialiser<T> {
|
||||
public abstract class SerialiserWithCraftingItem<T extends UpgradeBase> implements UpgradeSerialiser<T> {
|
||||
private final BiFunction<ResourceLocation, ItemStack, T> factory;
|
||||
|
||||
protected SerialiserWithCraftingItem(BiFunction<ResourceLocation, ItemStack, T> factory) {
|
||||
|
||||
@@ -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 @@ import java.util.function.Function;
|
||||
* @param <T> The upgrade that this class can serialise and deserialise.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public abstract class SimpleSerialiser<T extends IUpgradeBase> implements UpgradeSerialiser<T> {
|
||||
public abstract class SimpleSerialiser<T extends UpgradeBase> implements UpgradeSerialiser<T> {
|
||||
private final Function<ResourceLocation, T> constructor;
|
||||
|
||||
public SimpleSerialiser(Function<ResourceLocation, T> constructor) {
|
||||
|
||||
Reference in New Issue
Block a user