[1.20.3] Make Transfer API stable & remove previously deprecated API. ()

* Remove deprecated transfer APIs.

* Make Transfer API stable.
This commit is contained in:
modmuss 2023-10-08 13:01:41 +01:00 committed by GitHub
parent 10292b95f5
commit 0e870a06e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 5 additions and 355 deletions

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.client.fluid;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.client.item.TooltipContext;
@ -34,11 +33,7 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
/**
* Defines how {@linkplain FluidVariant fluid variants} of a given Fluid should be displayed to clients.
* Register with {@link FluidVariantRendering#register}.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface FluidVariantRenderHandler {
/**
* Append additional tooltips to the passed list if additional information is contained in the fluid variant.

View file

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.client.MinecraftClient;
@ -39,11 +38,7 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
/**
* Client-side display of fluid variants.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FluidVariantRendering {
private static final ApiProviderMap<Fluid, FluidVariantRenderHandler> HANDLERS = ApiProviderMap.create();
private static final FluidVariantRenderHandler DEFAULT_HANDLER = new FluidVariantRenderHandler() { };

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.context;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;
@ -39,7 +38,6 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
import net.fabricmc.fabric.impl.transfer.context.ConstantContainerItemContext;
import net.fabricmc.fabric.impl.transfer.context.CreativeInteractionContainerItemContext;
import net.fabricmc.fabric.impl.transfer.context.InitialContentsContainerItemContext;
import net.fabricmc.fabric.impl.transfer.context.PlayerContainerItemContext;
import net.fabricmc.fabric.impl.transfer.context.SingleSlotContainerItemContext;
@ -85,11 +83,7 @@ import net.fabricmc.fabric.impl.transfer.context.SingleSlotContainerItemContext;
* <li>Exchange some of the current variant with another variant through {@link #exchange}.
* In the water bucket example, this function can be used to combine steps 1, 2 and 3.</li>
* </ul>
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface ContainerItemContext {
/**
* Returns a context for interaction with a player's hand. This is recommended for item use interactions.
@ -168,33 +162,6 @@ public interface ContainerItemContext {
return new ConstantContainerItemContext(constantVariant, constantAmount);
}
/**
* Return a context that can accept anything, and will accept (and destroy) any overflow items, with some initial content.
* This can typically be used to check if a stack provides an API, or simulate operations on the returned API,
* for example to simulate how much fluid could be extracted from the stack.
*
* <p>Note that the stack can never be mutated by this function: its contents are copied directly.
*
* @deprecated Use {@link #withConstant(ItemStack)} instead.
*/
@Deprecated(forRemoval = true)
static ContainerItemContext withInitial(ItemStack initialContent) {
return withInitial(ItemVariant.of(initialContent), initialContent.getCount());
}
/**
* Return a context that can accept anything, and will accept (and destroy) any overflow items, with some initial variant and amount.
* This can typically be used to check if a variant provides an API, or simulate operations on the returned API,
* for example to simulate how much fluid could be extracted from the variant and amount.
*
* @deprecated Use {@link #withConstant(ItemVariant, long)} instead.
*/
@Deprecated(forRemoval = true)
static ContainerItemContext withInitial(ItemVariant initialVariant, long initialAmount) {
StoragePreconditions.notNegative(initialAmount);
return new InitialContentsContainerItemContext(initialVariant, initialAmount);
}
/**
* Try to find an API instance for the passed lookup and return it, or {@code null} if there is none.
* The API is queried for the current variant, if it's not blank.

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid;
import java.util.Collection;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
@ -47,11 +46,7 @@ import net.fabricmc.fabric.impl.transfer.fluid.CauldronStorage;
* </li>
* <li>{@code amountPerLevel} defines how much fluid (in droplets) there is in one level of the cauldron.</li>
* </ul>
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class CauldronFluidContent {
/**
* Block of the cauldron.

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.fluid;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.fluid.FlowableFluid;
/**
@ -25,11 +23,7 @@ import net.minecraft.fluid.FlowableFluid;
*
* <p>If you don't know how many droplets you should pick for a specific resource that has a block form,
* the convention is to use 81000 droplets for what is worth one block of that resource.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FluidConstants {
///////////////////////////
// ==== FLUID UNITS ==== //

View file

@ -16,15 +16,14 @@
package net.fabricmc.fabric.api.transfer.v1.fluid;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.BucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtil;
import net.minecraft.potion.Potions;
import net.minecraft.util.Identifier;
@ -33,24 +32,20 @@ import net.minecraft.util.math.Direction;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup;
import net.fabricmc.fabric.api.lookup.v1.item.ItemApiLookup;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
import net.fabricmc.fabric.api.transfer.v1.fluid.base.EmptyItemFluidStorage;
import net.fabricmc.fabric.api.transfer.v1.fluid.base.FullItemFluidStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.impl.transfer.fluid.EmptyBucketStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.fabricmc.fabric.impl.transfer.fluid.CombinedProvidersImpl;
import net.fabricmc.fabric.impl.transfer.fluid.EmptyBucketStorage;
import net.fabricmc.fabric.impl.transfer.fluid.WaterPotionStorage;
import net.fabricmc.fabric.mixin.transfer.BucketItemAccessor;
/**
* Access to {@link Storage Storage&lt;FluidVariant&gt;} instances.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FluidStorage {
/**
* Sided block access to fluid variant storages.

View file

@ -18,8 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
@ -39,11 +37,7 @@ import net.fabricmc.fabric.impl.transfer.DebugMessages;
/**
* Helper functions to work with fluid storages.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FluidStorageUtil {
/**
* Try to make the item in a player hand "interact" with a fluid storage.

View file

@ -36,11 +36,7 @@ import net.fabricmc.fabric.impl.transfer.fluid.FluidVariantImpl;
*
* <p><b>Fluid variants must always be compared with {@code equals}, never by reference!</b>
* {@code hashCode} is guaranteed to be correct and constant time independently of the size of the NBT.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface FluidVariant extends TransferVariant<Fluid> {
/**

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid;
import java.util.Optional;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
@ -35,11 +34,7 @@ import net.minecraft.world.World;
/**
* Defines the common attributes of {@linkplain FluidVariant fluid variants} of a given Fluid.
* Register with {@link FluidVariantAttributes#register}.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface FluidVariantAttributeHandler {
/**
* Return the name that should be used for the passed fluid variant.

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid;
import java.util.Optional;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Blocks;
@ -37,11 +36,7 @@ import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
/**
* Common fluid variant attributes, accessible both client-side and server-side.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FluidVariantAttributes {
private static final ApiProviderMap<Fluid, FluidVariantAttributeHandler> HANDLERS = ApiProviderMap.create();
private static final FluidVariantAttributeHandler DEFAULT_HANDLER = new FluidVariantAttributeHandler() { };

View file

@ -20,8 +20,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
@ -55,11 +53,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
* (This is just for illustration purposes! In practice, Fabric API already registers storages for most buckets,
* and it is inefficient to have one storage registered per fluid
* so Fabric API has a storage that accepts any fluid with a corresponding full bucket).
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class EmptyItemFluidStorage implements InsertionOnlyStorage<FluidVariant> {
private final ContainerItemContext context;
private final Item emptyItem;

View file

@ -18,8 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid.base;
import java.util.function.Function;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.item.Item;
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
@ -37,11 +35,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
* however there is a second constructor that allows customizing the mapping.
*
* <p>This is used similarly to {@link EmptyItemFluidStorage}.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class FullItemFluidStorage implements ExtractionOnlyStorage<FluidVariant>, SingleSlotStorage<FluidVariant> {
private final ContainerItemContext context;
private final Item fullItem;

View file

@ -18,8 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.fluid.base;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.nbt.NbtCompound;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
@ -34,11 +32,7 @@ import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage;
*
* <p>This is a convenient specialization of {@link SingleVariantStorage} for fluids that additionally offers methods
* to read the contents of the storage from NBT.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class SingleFluidStorage extends SingleVariantStorage<FluidVariant> {
/**
* Create a fluid storage with a fixed capacity and a change handler.

View file

@ -45,11 +45,7 @@ import net.fabricmc.fabric.impl.transfer.item.InventoryStorageImpl;
*
* <p><b>Important note:</b> This wrapper assumes that the inventory owns its slots.
* If the inventory does not own its slots, for example because it delegates to another inventory, this wrapper should not be used!
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface InventoryStorage extends SlottedStorage<ItemVariant> {
/**

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.item;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Blocks;
@ -43,11 +42,7 @@ import net.fabricmc.fabric.mixin.transfer.DoubleInventoryAccessor;
/**
* Access to {@link Storage Storage&lt;ItemVariant&gt;} instances.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class ItemStorage {
/**
* Sided block access to item variant storages.

View file

@ -33,11 +33,7 @@ import net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant;
* An immutable count-less ItemStack, i.e. an immutable association of an item and an optional NBT compound tag.
*
* <p>Do not implement, use the static {@code of(...)} functions instead.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface ItemVariant extends TransferVariant<Item> {
/**

View file

@ -38,11 +38,7 @@ import net.fabricmc.fabric.impl.transfer.item.CursorSlotWrapper;
* However, {@link #insert} is overridden to behave like {@link #offer}.
* For simple insertions, {@link #offer} or {@link #offerOrDrop} is recommended.
* {@link #getSlots} can also be used and combined with {@link CombinedStorage} to retrieve a wrapper around a specific range of slots.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
// TODO: Consider explicitly syncing stacks by sending a ScreenHandlerSlotUpdateS2CPacket if that proves to be necessary.
// TODO: Vanilla doesn't seem to be doing it reliably, so we ignore it for now.

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.item.base;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.nbt.NbtCompound;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
@ -31,11 +29,7 @@ import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage;
*
* <p>This is a convenient specialization of {@link SingleVariantStorage} for items that additionally offers methods
* to read the contents of the storage from NBT.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class SingleItemStorage extends SingleVariantStorage<ItemVariant> {
@Override
protected final ItemVariant getBlankVariant() {

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.item.base;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.item.ItemStack;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
@ -35,11 +33,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant;
* If one of these two functions is overridden to always return false, implementors may also wish to override
* {@link #supportsInsertion} and/or {@link #supportsExtraction}.
* {@link #getCapacity(ItemVariant)} can be overridden to change the maximum capacity depending on the item variant.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class SingleStackStorage extends SnapshotParticipant<ItemStack> implements SingleSlotStorage<ItemVariant> {
/**
* Return the stack of this storage. It will be modified directly sometimes to avoid needless copies.

View file

@ -18,11 +18,10 @@ package net.fabricmc.fabric.api.transfer.v1.storage;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.UnmodifiableView;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
/**
@ -33,11 +32,7 @@ import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
* Checking whether a storage is slotted can be done using {@code instanceof}.
*
* @param <T> The type of the stored resources.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface SlottedStorage<T> extends Storage<T> {
/**
* Retrieve the number of slots in this storage.

View file

@ -18,9 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.storage;
import java.util.Iterator;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.ExtractionOnlyStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.InsertionOnlyStorage;
@ -61,11 +58,7 @@ import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
*
* @param <T> The type of the stored resources.
* @see Transaction
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface Storage<T> extends Iterable<StorageView<T>> {
/**
* Return an empty storage.
@ -212,44 +205,4 @@ public interface Storage<T> extends Iterable<StorageView<T>> {
static <T> Class<Storage<T>> asClass() {
return (Class<Storage<T>>) (Object) Storage.class;
}
/**
* Convenient helper to simulate an insertion, i.e. get the result of insert without modifying any state.
* The passed transaction may be null if a new transaction should be opened for the simulation.
* @see #insert
* @deprecated Either use transactions directly, or use {@link StorageUtil#simulateInsert}.
*/
@Deprecated(forRemoval = true)
default long simulateInsert(T resource, long maxAmount, @Nullable TransactionContext transaction) {
return StorageUtil.simulateInsert(this, resource, maxAmount, transaction);
}
/**
* Convenient helper to simulate an extraction, i.e. get the result of extract without modifying any state.
* The passed transaction may be null if a new transaction should be opened for the simulation.
* @see #extract
* @deprecated Either use transactions directly, or use {@link StorageUtil#simulateExtract}.
*/
@Deprecated(forRemoval = true)
default long simulateExtract(T resource, long maxAmount, @Nullable TransactionContext transaction) {
return StorageUtil.simulateExtract(this, resource, maxAmount, transaction);
}
/**
* Return a view over this storage, for a specific resource, or {@code null} if none is quickly available.
*
* <p>This function should only return a non-null view if this storage can provide it quickly,
* for example with a hashmap lookup.
* If returning the requested view would require iteration through a potentially large number of views,
* {@code null} should be returned instead.
*
* @param resource The resource for which a storage view is requested. May be blank, for example to estimate capacity.
* @return A view over this storage for the passed resource, or {@code null} if none is quickly available.
* @deprecated Deprecated for removal without direct replacement. Use {@link #insert}, {@link #extract} or {@link #iterator} instead.
*/
@Deprecated(forRemoval = true)
@Nullable
default StorageView<T> exactView(T resource) {
return null;
}
}

View file

@ -16,18 +16,12 @@
package net.fabricmc.fabric.api.transfer.v1.storage;
import org.jetbrains.annotations.ApiStatus;
/**
* Preconditions that can be used when working with storages.
*
* <p>In particular, {@link #notNegative} or {@link #notBlankNotNegative} can be used by implementations of
* {@link Storage#insert} and {@link Storage#extract} to fail-fast if the arguments are invalid.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class StoragePreconditions {
/**
* Ensure that the passed transfer variant is not blank.

View file

@ -20,7 +20,6 @@ import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.inventory.Inventory;
@ -39,11 +38,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
*
* <p>Note that the functions that take a predicate iterate over the entire inventory in the worst case.
* If the resource is known, there will generally be a more performance efficient way.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public final class StorageUtil {
private StorageUtil() {
}

View file

@ -16,19 +16,13 @@
package net.fabricmc.fabric.api.transfer.v1.storage;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
/**
* A view of a single stored resource in a {@link Storage}, for use with {@link Storage#iterator}.
*
* @param <T> The type of the stored resource.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface StorageView<T> {
/**
* Try to extract a resource from this view.

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.storage;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.nbt.NbtCompound;
@ -34,11 +33,7 @@ import net.minecraft.network.PacketByteBuf;
* {@code hashCode} is guaranteed to be correct and constant time independently of the size of the NBT.
*
* @param <O> The type of the immutable object instance, for example {@code Item} or {@code Fluid}.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface TransferVariant<O> {
/**
* Return true if this variant is blank, and false otherwise.

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.storage.base;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
import net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
@ -25,11 +23,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
/**
* A transfer variant storage view that contains a blank variant all the time (it's always empty), but may have a nonzero capacity.
* This can be used to give capacity hints even if the storage is empty.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public class BlankVariantView<T extends TransferVariant<?>> implements StorageView<T> {
private final T blankVariant;
private final long capacity;

View file

@ -19,8 +19,6 @@ package net.fabricmc.fabric.api.transfer.v1.storage.base;
import java.util.List;
import java.util.StringJoiner;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
@ -30,11 +28,7 @@ import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
*
* @param <T> The type of the stored resources.
* @param <S> The class of every part. {@code ? extends Storage<T>} can be used if the parts are of different types.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public class CombinedSlottedStorage<T, S extends SlottedStorage<T>> extends CombinedStorage<T, S> implements SlottedStorage<T> {
public CombinedSlottedStorage(List<S> parts) {
super(parts);

View file

@ -21,8 +21,6 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.StringJoiner;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
@ -35,11 +33,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
*
* @param <T> The type of the stored resources.
* @param <S> The class of every part. {@code ? extends Storage<T>} can be used if the parts are of different types.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public class CombinedStorage<T, S extends Storage<T>> implements Storage<T> {
public List<S> parts;

View file

@ -16,18 +16,12 @@
package net.fabricmc.fabric.api.transfer.v1.storage.base;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
/**
* A {@link Storage} that supports extraction, and not insertion.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface ExtractionOnlyStorage<T> extends Storage<T> {
@Override
default boolean supportsInsertion() {

View file

@ -20,8 +20,6 @@ import java.util.Iterator;
import java.util.function.Supplier;
import com.google.common.collect.Iterators;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
@ -37,11 +35,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
* <p>The static functions can be used when insertion or/and extraction should be blocked entirely.
*
* @param <T> The type of the stored resources.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class FilteringStorage<T> implements Storage<T> {
/**
* Return a wrapper over the passed storage that prevents extraction.
@ -165,18 +159,6 @@ public abstract class FilteringStorage<T> implements Storage<T> {
return Iterators.transform(backingStorage.get().iterator(), FilteringStorageView::new);
}
@Override
@Nullable
public StorageView<T> exactView(T resource) {
StorageView<T> exact = backingStorage.get().exactView(resource);
if (exact != null) {
return new FilteringStorageView(exact);
} else {
return null;
}
}
@Override
public long getVersion() {
return backingStorage.get().getVersion();

View file

@ -19,19 +19,13 @@ package net.fabricmc.fabric.api.transfer.v1.storage.base;
import java.util.Collections;
import java.util.Iterator;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
/**
* A {@link Storage} that supports insertion, and not extraction. By default, it doesn't have any storage view either.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface InsertionOnlyStorage<T> extends Storage<T> {
@Override
default boolean supportsExtraction() {

View file

@ -16,15 +16,9 @@
package net.fabricmc.fabric.api.transfer.v1.storage.base;
import org.jetbrains.annotations.ApiStatus;
/**
* An immutable object storing both a resource and an amount, provided for convenience.
* @param <T> The type of the stored resource.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public record ResourceAmount<T> (T resource, long amount) {
}

View file

@ -18,8 +18,6 @@ package net.fabricmc.fabric.api.transfer.v1.storage.base;
import java.util.Iterator;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
@ -29,11 +27,7 @@ import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
* It can be used in APIs for storages that are wrappers around a single "slot", or for slightly more convenient implementation.
*
* @param <T> The type of the stored resource.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public interface SingleSlotStorage<T> extends SlottedStorage<T>, StorageView<T> {
@Override
default Iterator<StorageView<T>> iterator() {

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.storage.base;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -46,11 +44,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
* </ul>
*
* @param <T> The type of the stored transfer variant.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class SingleVariantItemStorage<T extends TransferVariant<?>> implements SingleSlotStorage<T> {
/**
* Reference to the context.

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.api.transfer.v1.storage.base;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.nbt.NbtCompound;
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
@ -34,13 +32,9 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant;
* If one of these two functions is overridden to always return false, implementors may also wish to override
* {@link #supportsInsertion} and/or {@link #supportsExtraction}.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*
* @see net.fabricmc.fabric.api.transfer.v1.fluid.base.SingleFluidStorage SingleFluidStorage for fluid variants.
* @see net.fabricmc.fabric.api.transfer.v1.item.base.SingleItemStorage SingleItemStorage for item variants.
*/
@ApiStatus.Experimental
public abstract class SingleVariantStorage<T extends TransferVariant<?>> extends SnapshotParticipant<ResourceAmount<T>> implements SingleSlotStorage<T> {
public T variant = getBlankVariant();
public long amount = 0;

View file

@ -73,11 +73,7 @@ import net.fabricmc.fabric.impl.transfer.transaction.TransactionManagerImpl;
* <p>Every transaction is only valid on the thread it was opened on,
* and attempts to use it on another thread will throw an exception.
* Consequently, transactions can be concurrent across multiple threads, as long as they don't share any state.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface Transaction extends AutoCloseable, TransactionContext {
/**

View file

@ -21,11 +21,7 @@ import org.jetbrains.annotations.ApiStatus;
/**
* A subset of a {@link Transaction} that lets participants properly take part in transactions, manage their state,
* or open nested transactions, but does not allow them to close the transaction they are passed.
*
* <p><b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface TransactionContext {
/**

View file

@ -20,8 +20,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.jetbrains.annotations.ApiStatus;
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
@ -53,11 +51,7 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
* and {@link #onFinalCommit} will be called after the transaction is closed.
*
* @param <T> The objects that this participant uses to save its state snapshots.
*
* <b>Experimental feature</b>, we reserve the right to remove or change it without further notice.
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public abstract class SnapshotParticipant<T> implements Transaction.CloseCallback, Transaction.OuterCloseCallback {
private final List<T> snapshots = new ArrayList<>();

View file

@ -1,64 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.impl.transfer.context;
import java.util.Collections;
import java.util.List;
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
@Deprecated(forRemoval = true)
public class InitialContentsContainerItemContext implements ContainerItemContext {
private final SingleVariantStorage<ItemVariant> backingSlot = new SingleVariantStorage<>() {
@Override
protected ItemVariant getBlankVariant() {
return ItemVariant.blank();
}
@Override
protected long getCapacity(ItemVariant variant) {
return Long.MAX_VALUE;
}
};
public InitialContentsContainerItemContext(ItemVariant initialVariant, long initialAmount) {
backingSlot.variant = initialVariant;
backingSlot.amount = initialAmount;
}
@Override
public SingleSlotStorage<ItemVariant> getMainSlot() {
return backingSlot;
}
@Override
public long insertOverflow(ItemVariant itemVariant, long maxAmount, TransactionContext transactionContext) {
StoragePreconditions.notBlankNotNegative(itemVariant, maxAmount);
// Always allow anything to be inserted.
return maxAmount;
}
@Override
public List<SingleSlotStorage<ItemVariant>> getAdditionalSlots() {
return Collections.emptyList();
}
}

View file

@ -25,6 +25,6 @@
"fabric-transfer-api-v1.mixins.json"
],
"custom": {
"fabric-api:module-lifecycle": "experimental"
"fabric-api:module-lifecycle": "stable"
}
}