mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 23:13:15 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
import net.minecraft.core.BlockSource;
|
||||
@@ -18,6 +16,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Fills or drains a fluid container item using a Dispenser.
|
||||
@@ -36,8 +35,8 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
private final DefaultDispenseItemBehavior dispenseBehavior = new DefaultDispenseItemBehavior();
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack execute(@Nonnull BlockSource source, @Nonnull ItemStack stack)
|
||||
@NotNull
|
||||
public ItemStack execute(@NotNull BlockSource source, @NotNull ItemStack stack)
|
||||
{
|
||||
if (FluidUtil.getFluidContained(stack).isPresent())
|
||||
{
|
||||
@@ -52,8 +51,8 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
/**
|
||||
* Picks up fluid in front of a Dispenser and fills a container with it.
|
||||
*/
|
||||
@Nonnull
|
||||
private ItemStack fillContainer(@Nonnull BlockSource source, @Nonnull ItemStack stack)
|
||||
@NotNull
|
||||
private ItemStack fillContainer(@NotNull BlockSource source, @NotNull ItemStack stack)
|
||||
{
|
||||
Level level = source.getLevel();
|
||||
Direction dispenserFacing = source.getBlockState().getValue(DispenserBlock.FACING);
|
||||
@@ -84,8 +83,8 @@ public class DispenseFluidContainer extends DefaultDispenseItemBehavior
|
||||
/**
|
||||
* Drains a filled container and places the fluid in front of the Dispenser.
|
||||
*/
|
||||
@Nonnull
|
||||
private ItemStack dumpContainer(BlockSource source, @Nonnull ItemStack stack)
|
||||
@NotNull
|
||||
private ItemStack dumpContainer(BlockSource source, @NotNull ItemStack stack)
|
||||
{
|
||||
ItemStack singleStack = stack.copy();
|
||||
singleStack.setCount(1);
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Holds the result of a fluid action from {@link FluidUtil}.
|
||||
@@ -23,15 +22,15 @@ public class FluidActionResult
|
||||
public static final FluidActionResult FAILURE = new FluidActionResult(false, ItemStack.EMPTY);
|
||||
|
||||
public final boolean success;
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public final ItemStack result;
|
||||
|
||||
public FluidActionResult(@Nonnull ItemStack result)
|
||||
public FluidActionResult(@NotNull ItemStack result)
|
||||
{
|
||||
this(true, result);
|
||||
}
|
||||
|
||||
private FluidActionResult(boolean success, @Nonnull ItemStack result)
|
||||
private FluidActionResult(boolean success, @NotNull ItemStack result)
|
||||
{
|
||||
this.success = success;
|
||||
this.result = result;
|
||||
@@ -42,7 +41,7 @@ public class FluidActionResult
|
||||
return success;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public ItemStack getResult()
|
||||
{
|
||||
return result;
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
@@ -15,7 +13,6 @@ import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
@@ -33,6 +30,8 @@ import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Minecraft Forge Fluid Implementation
|
||||
@@ -126,7 +125,7 @@ public class FluidAttributes
|
||||
|
||||
protected FluidAttributes(Builder builder, Fluid fluid)
|
||||
{
|
||||
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeDescriptionId("fluid", fluid.getRegistryName());
|
||||
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeDescriptionId("fluid", ForgeRegistries.FLUIDS.getKey(fluid));
|
||||
this.stillTexture = builder.stillTexture;
|
||||
this.flowingTexture = builder.flowingTexture;
|
||||
this.overlayTexture = builder.overlayTexture;
|
||||
@@ -213,7 +212,7 @@ public class FluidAttributes
|
||||
*/
|
||||
public Component getDisplayName(FluidStack stack)
|
||||
{
|
||||
return new TranslatableComponent(getTranslationKey());
|
||||
return Component.translatable(getTranslationKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ package net.minecraftforge.fluids;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
@@ -17,12 +18,10 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -55,7 +54,7 @@ public class FluidStack
|
||||
private boolean isEmpty;
|
||||
private int amount;
|
||||
private CompoundTag tag;
|
||||
private IRegistryDelegate<Fluid> fluidDelegate;
|
||||
private Holder.Reference<Fluid> fluidDelegate;
|
||||
|
||||
public FluidStack(Fluid fluid, int amount)
|
||||
{
|
||||
@@ -66,10 +65,10 @@ public class FluidStack
|
||||
}
|
||||
else if (ForgeRegistries.FLUIDS.getKey(fluid) == null)
|
||||
{
|
||||
LOGGER.fatal("Failed attempt to create a FluidStack for an unregistered Fluid {} (type {})", fluid.getRegistryName(), fluid.getClass().getName());
|
||||
LOGGER.fatal("Failed attempt to create a FluidStack for an unregistered Fluid {} (type {})", ForgeRegistries.FLUIDS.getKey(fluid), fluid.getClass().getName());
|
||||
throw new IllegalArgumentException("Cannot create a fluidstack from an unregistered fluid");
|
||||
}
|
||||
this.fluidDelegate = fluid.delegate;
|
||||
this.fluidDelegate = ForgeRegistries.FLUIDS.getDelegateOrThrow(fluid);
|
||||
this.amount = amount;
|
||||
|
||||
updateEmpty();
|
||||
@@ -122,7 +121,7 @@ public class FluidStack
|
||||
|
||||
public CompoundTag writeToNBT(CompoundTag nbt)
|
||||
{
|
||||
nbt.putString("FluidName", getFluid().getRegistryName().toString());
|
||||
nbt.putString("FluidName", ForgeRegistries.FLUIDS.getKey(getFluid()).toString());
|
||||
nbt.putInt("Amount", amount);
|
||||
|
||||
if (tag != null)
|
||||
@@ -134,7 +133,7 @@ public class FluidStack
|
||||
|
||||
public void writeToPacket(FriendlyByteBuf buf)
|
||||
{
|
||||
buf.writeRegistryId(getFluid());
|
||||
buf.writeRegistryId(ForgeRegistries.FLUIDS, getFluid());
|
||||
buf.writeVarInt(getAmount());
|
||||
buf.writeNbt(tag);
|
||||
}
|
||||
@@ -258,7 +257,7 @@ public class FluidStack
|
||||
* The FluidStack for comparison
|
||||
* @return true if the Fluids (IDs and NBT Tags) are the same
|
||||
*/
|
||||
public boolean isFluidEqual(@Nonnull FluidStack other)
|
||||
public boolean isFluidEqual(@NotNull FluidStack other)
|
||||
{
|
||||
return getFluid() == other.getFluid() && isFluidStackTagEqual(other);
|
||||
}
|
||||
@@ -271,7 +270,7 @@ public class FluidStack
|
||||
/**
|
||||
* Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal.
|
||||
*/
|
||||
public static boolean areFluidStackTagsEqual(@Nonnull FluidStack stack1, @Nonnull FluidStack stack2)
|
||||
public static boolean areFluidStackTagsEqual(@NotNull FluidStack stack1, @NotNull FluidStack stack2)
|
||||
{
|
||||
return stack1.isFluidStackTagEqual(stack2);
|
||||
}
|
||||
@@ -281,7 +280,7 @@ public class FluidStack
|
||||
*
|
||||
* @return true if this FluidStack contains the other FluidStack (same fluid and >= amount)
|
||||
*/
|
||||
public boolean containsFluid(@Nonnull FluidStack other)
|
||||
public boolean containsFluid(@NotNull FluidStack other)
|
||||
{
|
||||
return isFluidEqual(other) && amount >= other.amount;
|
||||
}
|
||||
@@ -306,7 +305,7 @@ public class FluidStack
|
||||
* The ItemStack for comparison
|
||||
* @return true if the Fluids (IDs and NBT Tags) are the same
|
||||
*/
|
||||
public boolean isFluidEqual(@Nonnull ItemStack other)
|
||||
public boolean isFluidEqual(@NotNull ItemStack other)
|
||||
{
|
||||
return FluidUtil.getFluidContained(other).map(this::isFluidEqual).orElse(false);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -43,6 +40,8 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FluidUtil
|
||||
{
|
||||
@@ -63,7 +62,7 @@ public class FluidUtil
|
||||
* @param side The side of the block to interact with. May be null.
|
||||
* @return true if the interaction succeeded and updated the item held by the player, false otherwise.
|
||||
*/
|
||||
public static boolean interactWithFluidHandler(@Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull Level level, @Nonnull BlockPos pos, @Nullable Direction side)
|
||||
public static boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull Level level, @NotNull BlockPos pos, @Nullable Direction side)
|
||||
{
|
||||
Preconditions.checkNotNull(level);
|
||||
Preconditions.checkNotNull(pos);
|
||||
@@ -82,7 +81,7 @@ public class FluidUtil
|
||||
* @param handler The fluid handler.
|
||||
* @return true if the interaction succeeded and updated the item held by the player, false otherwise.
|
||||
*/
|
||||
public static boolean interactWithFluidHandler(@Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull IFluidHandler handler)
|
||||
public static boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull IFluidHandler handler)
|
||||
{
|
||||
Preconditions.checkNotNull(player);
|
||||
Preconditions.checkNotNull(hand);
|
||||
@@ -124,8 +123,8 @@ public class FluidUtil
|
||||
* @param doFill true if the container should actually be filled, false if it should be simulated.
|
||||
* @return a {@link FluidActionResult} holding the filled container if successful.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryFillContainer(@Nonnull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable Player player, boolean doFill)
|
||||
@NotNull
|
||||
public static FluidActionResult tryFillContainer(@NotNull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable Player player, boolean doFill)
|
||||
{
|
||||
ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input
|
||||
return getFluidHandler(containerCopy)
|
||||
@@ -168,8 +167,8 @@ public class FluidUtil
|
||||
* @return a {@link FluidActionResult} holding the empty container if the fluid handler was filled.
|
||||
* NOTE If the container is consumable, the empty container will be null on success.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryEmptyContainer(@Nonnull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable Player player, boolean doDrain)
|
||||
@NotNull
|
||||
public static FluidActionResult tryEmptyContainer(@NotNull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable Player player, boolean doDrain)
|
||||
{
|
||||
ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input
|
||||
return getFluidHandler(containerCopy)
|
||||
@@ -209,8 +208,8 @@ public class FluidUtil
|
||||
* @param doFill true if the container should actually be filled, false if it should be simulated.
|
||||
* @return a {@link FluidActionResult} holding the result and the resulting container. The resulting container is empty on failure.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryFillContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doFill)
|
||||
@NotNull
|
||||
public static FluidActionResult tryFillContainerAndStow(@NotNull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doFill)
|
||||
{
|
||||
if (container.isEmpty())
|
||||
{
|
||||
@@ -277,8 +276,8 @@ public class FluidUtil
|
||||
* @param doDrain true if the container should actually be drained, false if it should be simulated.
|
||||
* @return a {@link FluidActionResult} holding the result and the resulting container. The resulting container is empty on failure.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryEmptyContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doDrain)
|
||||
@NotNull
|
||||
public static FluidActionResult tryEmptyContainerAndStow(@NotNull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable Player player, boolean doDrain)
|
||||
{
|
||||
if (container.isEmpty())
|
||||
{
|
||||
@@ -340,7 +339,7 @@ public class FluidUtil
|
||||
* @param doTransfer True if the transfer should actually be done, false if it should be simulated.
|
||||
* @return the fluidStack that was transferred from the source to the destination. null on failure.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public static FluidStack tryFluidTransfer(IFluidHandler fluidDestination, IFluidHandler fluidSource, int maxAmount, boolean doTransfer)
|
||||
{
|
||||
FluidStack drainable = fluidSource.drain(maxAmount, IFluidHandler.FluidAction.SIMULATE);
|
||||
@@ -362,7 +361,7 @@ public class FluidUtil
|
||||
* @param doTransfer True if the transfer should actually be done, false if it should be simulated.
|
||||
* @return the fluidStack that was transferred from the source to the destination. null on failure.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public static FluidStack tryFluidTransfer(IFluidHandler fluidDestination, IFluidHandler fluidSource, FluidStack resource, boolean doTransfer)
|
||||
{
|
||||
FluidStack drainable = fluidSource.drain(resource, IFluidHandler.FluidAction.SIMULATE);
|
||||
@@ -380,7 +379,7 @@ public class FluidUtil
|
||||
* Modders: Instead of this method, use {@link #tryFluidTransfer(IFluidHandler, IFluidHandler, FluidStack, boolean)}
|
||||
* or {@link #tryFluidTransfer(IFluidHandler, IFluidHandler, int, boolean)}.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
private static FluidStack tryFluidTransfer_Internal(IFluidHandler fluidDestination, IFluidHandler fluidSource, FluidStack drainable, boolean doTransfer)
|
||||
{
|
||||
int fillableAmount = fluidDestination.fill(drainable, IFluidHandler.FluidAction.SIMULATE);
|
||||
@@ -416,7 +415,7 @@ public class FluidUtil
|
||||
*
|
||||
* Vanilla buckets will be converted to universal buckets if they are enabled.
|
||||
*/
|
||||
public static LazyOptional<IFluidHandlerItem> getFluidHandler(@Nonnull ItemStack itemStack)
|
||||
public static LazyOptional<IFluidHandlerItem> getFluidHandler(@NotNull ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
|
||||
}
|
||||
@@ -424,7 +423,7 @@ public class FluidUtil
|
||||
/**
|
||||
* Helper method to get the fluid contained in an itemStack
|
||||
*/
|
||||
public static Optional<FluidStack> getFluidContained(@Nonnull ItemStack container)
|
||||
public static Optional<FluidStack> getFluidContained(@NotNull ItemStack container)
|
||||
{
|
||||
if (!container.isEmpty())
|
||||
{
|
||||
@@ -469,8 +468,8 @@ public class FluidUtil
|
||||
* @param side The side of the fluid that is being drained.
|
||||
* @return a {@link FluidActionResult} holding the result and the resulting container.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryPickUpFluid(@Nonnull ItemStack emptyContainer, @Nullable Player playerIn, Level level, BlockPos pos, Direction side)
|
||||
@NotNull
|
||||
public static FluidActionResult tryPickUpFluid(@NotNull ItemStack emptyContainer, @Nullable Player playerIn, Level level, BlockPos pos, Direction side)
|
||||
{
|
||||
if (emptyContainer.isEmpty() || level == null || pos == null)
|
||||
{
|
||||
@@ -512,8 +511,8 @@ public class FluidUtil
|
||||
* @param resource The fluidStack to place
|
||||
* @return the container's ItemStack with the remaining amount of fluid if the placement was successful, null otherwise
|
||||
*/
|
||||
@Nonnull
|
||||
public static FluidActionResult tryPlaceFluid(@Nullable Player player, Level level, InteractionHand hand, BlockPos pos, @Nonnull ItemStack container, FluidStack resource)
|
||||
@NotNull
|
||||
public static FluidActionResult tryPlaceFluid(@Nullable Player player, Level level, InteractionHand hand, BlockPos pos, @NotNull ItemStack container, FluidStack resource)
|
||||
{
|
||||
ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input
|
||||
return getFluidHandler(containerCopy)
|
||||
@@ -644,8 +643,8 @@ public class FluidUtil
|
||||
* @return a filled vanilla bucket or filled universal bucket.
|
||||
* Returns empty itemStack if none of the enabled buckets can hold the fluid.
|
||||
*/
|
||||
@Nonnull
|
||||
public static ItemStack getFilledBucket(@Nonnull FluidStack fluidStack)
|
||||
@NotNull
|
||||
public static ItemStack getFilledBucket(@NotNull FluidStack fluidStack)
|
||||
{
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -24,8 +23,9 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
@@ -132,7 +132,7 @@ public abstract class ForgeFlowingFluid extends FlowingFluid
|
||||
return fluidIn == still.get() || fluidIn == flowing.get();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public Optional<SoundEvent> getPickupSound()
|
||||
{
|
||||
|
||||
@@ -9,8 +9,7 @@ import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implement this interface on Block classes which represent world-placeable Fluids.
|
||||
@@ -35,7 +34,7 @@ public interface IFluidBlock
|
||||
* @param action If SIMULATE, the placement will only be simulated
|
||||
* @return the amount of fluid extracted from the provided stack to achieve some fluid level
|
||||
*/
|
||||
int place(Level level, BlockPos pos, @Nonnull FluidStack fluidStack, IFluidHandler.FluidAction action);
|
||||
int place(Level level, BlockPos pos, @NotNull FluidStack fluidStack, IFluidHandler.FluidAction action);
|
||||
|
||||
/**
|
||||
* Attempt to drain the block. This method should be called by devices such as pumps.
|
||||
@@ -46,7 +45,7 @@ public interface IFluidBlock
|
||||
* If SIMULATE, the drain will only be simulated.
|
||||
* @return the fluid stack after draining the block
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack drain(Level level, BlockPos pos, IFluidHandler.FluidAction action);
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This interface represents a Fluid Tank. IT IS NOT REQUIRED but is provided for convenience.
|
||||
@@ -19,7 +18,7 @@ public interface IFluidTank {
|
||||
/**
|
||||
* @return FluidStack representing the fluid in the tank, null if the tank is empty.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack getFluid();
|
||||
|
||||
/**
|
||||
@@ -50,7 +49,7 @@ public interface IFluidTank {
|
||||
* @param action If SIMULATE, the drain will only be simulated.
|
||||
* @return Amount of fluid that was removed (or would be, if simulated) from the tank.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack drain(int maxDrain, FluidAction action);
|
||||
|
||||
/**
|
||||
@@ -58,7 +57,7 @@ public interface IFluidTank {
|
||||
* @param action If SIMULATE, the drain will only be simulated.
|
||||
* @return FluidStack representing fluid that was removed (or would be, if simulated) from the tank.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack drain(FluidStack resource, FluidAction action);
|
||||
|
||||
}
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraftforge.fluids.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implement this interface as a capability which should handle fluids, generally storing them in
|
||||
@@ -52,7 +51,7 @@ public interface IFluidHandler
|
||||
* @param tank Tank to query.
|
||||
* @return FluidStack in a given tank. FluidStack.EMPTY if the tank is empty.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack getFluidInTank(int tank);
|
||||
|
||||
/**
|
||||
@@ -72,7 +71,7 @@ public interface IFluidHandler
|
||||
* @return TRUE if the tank can hold the FluidStack, not considering current state.
|
||||
* (Basically, is a given fluid EVER allowed in this tank?) Return FALSE if the answer to that question is 'no.'
|
||||
*/
|
||||
boolean isFluidValid(int tank, @Nonnull FluidStack stack);
|
||||
boolean isFluidValid(int tank, @NotNull FluidStack stack);
|
||||
|
||||
/**
|
||||
* Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler.
|
||||
@@ -91,7 +90,7 @@ public interface IFluidHandler
|
||||
* @return FluidStack representing the Fluid and amount that was (or would have been, if
|
||||
* simulated) drained.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack drain(FluidStack resource, FluidAction action);
|
||||
|
||||
/**
|
||||
@@ -104,7 +103,7 @@ public interface IFluidHandler
|
||||
* @return FluidStack representing the Fluid and amount that was (or would have been, if
|
||||
* simulated) drained.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
FluidStack drain(int maxDrain, FluidAction action);
|
||||
|
||||
}
|
||||
@@ -5,9 +5,8 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* ItemStacks handled by an {@link IFluidHandler} may change, so this class allows
|
||||
@@ -21,6 +20,6 @@ public interface IFluidHandlerItem extends IFluidHandler
|
||||
* for their filled and empty states.
|
||||
* May be an empty item if the container was drained and is consumable.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
ItemStack getContainer();
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A simple fluid container, to replace the functionality of the old FluidContainerRegistry and IFluidContainerItem.
|
||||
@@ -33,7 +32,7 @@ public class ItemFluidContainer extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable CompoundTag nbt)
|
||||
public ICapabilityProvider initCapabilities(@NotNull ItemStack stack, @Nullable CompoundTag nbt)
|
||||
{
|
||||
return new FluidHandlerItemStack(stack, capacity);
|
||||
}
|
||||
|
||||
@@ -15,17 +15,16 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TileFluidHandler extends BlockEntity
|
||||
{
|
||||
protected FluidTank tank = new FluidTank(FluidAttributes.BUCKET_VOLUME);
|
||||
|
||||
|
||||
private final LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank);
|
||||
|
||||
public TileFluidHandler(@Nonnull BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state)
|
||||
public TileFluidHandler(@NotNull BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state)
|
||||
{
|
||||
super(blockEntityType, pos, state);
|
||||
}
|
||||
@@ -45,8 +44,8 @@ public class TileFluidHandler extends BlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
||||
@NotNull
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction facing)
|
||||
{
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||
return holder.cast();
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.templates;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EmptyFluidHandler implements IFluidHandler
|
||||
{
|
||||
@@ -21,7 +19,7 @@ public class EmptyFluidHandler implements IFluidHandler
|
||||
@Override
|
||||
public int getTanks() { return 1; }
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) { return FluidStack.EMPTY; }
|
||||
|
||||
@@ -29,7 +27,7 @@ public class EmptyFluidHandler implements IFluidHandler
|
||||
public int getTankCapacity(int tank) { return 0; }
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { return true; }
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) { return true; }
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
@@ -37,14 +35,14 @@ public class EmptyFluidHandler implements IFluidHandler
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
|
||||
+12
-14
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.templates;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -18,7 +15,8 @@ import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* FluidHandlerItemStack is a template capability provider for ItemStacks.
|
||||
@@ -35,7 +33,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
|
||||
private final LazyOptional<IFluidHandlerItem> holder = LazyOptional.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected ItemStack container;
|
||||
protected int capacity;
|
||||
|
||||
@@ -43,20 +41,20 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
* @param container The container itemStack, data is stored on it directly as NBT.
|
||||
* @param capacity The maximum capacity of this fluid tank.
|
||||
*/
|
||||
public FluidHandlerItemStack(@Nonnull ItemStack container, int capacity)
|
||||
public FluidHandlerItemStack(@NotNull ItemStack container, int capacity)
|
||||
{
|
||||
this.container = container;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getContainer()
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
CompoundTag tagCompound = container.getTag();
|
||||
@@ -85,7 +83,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
|
||||
@@ -99,7 +97,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) {
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -144,7 +142,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -155,7 +153,7 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
return drain(resource.getAmount(), action);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
@@ -211,8 +209,8 @@ public class FluidHandlerItemStack implements IFluidHandlerItem, ICapabilityProv
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
||||
@NotNull
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction facing)
|
||||
{
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY.orEmpty(capability, holder);
|
||||
}
|
||||
|
||||
+13
-15
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.templates;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -18,7 +15,8 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* FluidHandlerItemStackSimple is a template capability provider for ItemStacks.
|
||||
@@ -32,7 +30,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
|
||||
private final LazyOptional<IFluidHandlerItem> holder = LazyOptional.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected ItemStack container;
|
||||
protected int capacity;
|
||||
|
||||
@@ -40,20 +38,20 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
* @param container The container itemStack, data is stored on it directly as NBT.
|
||||
* @param capacity The maximum capacity of this fluid tank.
|
||||
*/
|
||||
public FluidHandlerItemStackSimple(@Nonnull ItemStack container, int capacity)
|
||||
public FluidHandlerItemStackSimple(@NotNull ItemStack container, int capacity)
|
||||
{
|
||||
this.container = container;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getContainer()
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
CompoundTag tagCompound = container.getTag();
|
||||
@@ -82,7 +80,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
|
||||
@@ -96,13 +94,13 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(@Nonnull FluidStack resource, FluidAction action)
|
||||
public int fill(@NotNull FluidStack resource, FluidAction action)
|
||||
{
|
||||
if (container.getCount() != 1 || resource.isEmpty() || !canFillFluidType(resource))
|
||||
{
|
||||
@@ -127,7 +125,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -138,7 +136,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
return drain(resource.getAmount(), action);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
@@ -188,8 +186,8 @@ public class FluidHandlerItemStackSimple implements IFluidHandlerItem, ICapabili
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
||||
@NotNull
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction facing)
|
||||
{
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY.orEmpty(capability, holder);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
@@ -22,7 +21,7 @@ import java.util.function.Predicate;
|
||||
public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
|
||||
protected Predicate<FluidStack> validator;
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected FluidStack fluid = FluidStack.EMPTY;
|
||||
protected int capacity;
|
||||
|
||||
@@ -61,7 +60,7 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
return fluid;
|
||||
@@ -92,7 +91,7 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
|
||||
@@ -106,7 +105,7 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) {
|
||||
|
||||
return isFluidValid(stack);
|
||||
}
|
||||
@@ -156,7 +155,7 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
return filled;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -167,7 +166,7 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
return drain(resource.getAmount(), action);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
|
||||
@@ -8,9 +8,7 @@ package net.minecraftforge.fluids.capability.templates;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* VoidFluidHandler is a template fluid handler that can be filled indefinitely without ever getting full.
|
||||
@@ -25,7 +23,7 @@ public class VoidFluidHandler implements IFluidHandler
|
||||
@Override
|
||||
public int getTanks() { return 1; }
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) { return FluidStack.EMPTY; }
|
||||
|
||||
@@ -33,7 +31,7 @@ public class VoidFluidHandler implements IFluidHandler
|
||||
public int getTankCapacity(int tank) { return Integer.MAX_VALUE; }
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { return true; }
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) { return true; }
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
@@ -41,14 +39,14 @@ public class VoidFluidHandler implements IFluidHandler
|
||||
return resource.getAmount();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
|
||||
+7
-7
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.wrappers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.BucketPickup;
|
||||
@@ -16,8 +14,10 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack)
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -93,7 +93,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
{
|
||||
//Be loud if something went wrong
|
||||
LOGGER.error("Fluid removed without successfully being picked up. Fluid {} at {} in {} matched requested type, but after performing pickup was {}.",
|
||||
fluidState.getType().getRegistryName(), blockPos, world.dimension().location(), bucket.getFluid().getRegistryName());
|
||||
ForgeRegistries.FLUIDS.getKey(fluidState.getType()), blockPos, world.dimension().location(), ForgeRegistries.FLUIDS.getKey(bucket.getFluid()));
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
return extracted;
|
||||
@@ -113,7 +113,7 @@ public class BucketPickupHandlerWrapper implements IFluidHandler
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.wrappers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
@@ -13,7 +12,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FluidBlockWrapper implements IFluidHandler
|
||||
{
|
||||
@@ -34,7 +33,7 @@ public class FluidBlockWrapper implements IFluidHandler
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank)
|
||||
{
|
||||
@@ -57,7 +56,7 @@ public class FluidBlockWrapper implements IFluidHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack)
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack)
|
||||
{
|
||||
return stack.getFluid() == fluidBlock.getFluid();
|
||||
}
|
||||
@@ -68,7 +67,7 @@ public class FluidBlockWrapper implements IFluidHandler
|
||||
return fluidBlock.place(world, blockPos, resource, action);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -87,7 +86,7 @@ public class FluidBlockWrapper implements IFluidHandler
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
|
||||
+14
-17
@@ -5,9 +5,6 @@
|
||||
|
||||
package net.minecraftforge.fluids.capability.wrappers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
@@ -20,13 +17,13 @@ import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
|
||||
import net.minecraft.world.item.BucketItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.MilkBucketItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Wrapper for vanilla and forge buckets.
|
||||
@@ -36,15 +33,15 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
{
|
||||
private final LazyOptional<IFluidHandlerItem> holder = LazyOptional.of(() -> this);
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected ItemStack container;
|
||||
|
||||
public FluidBucketWrapper(@Nonnull ItemStack container)
|
||||
public FluidBucketWrapper(@NotNull ItemStack container)
|
||||
{
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getContainer()
|
||||
{
|
||||
@@ -60,7 +57,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
return !fluid.getFluid().getAttributes().getBucket(fluid).isEmpty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
Item item = container.getItem();
|
||||
@@ -78,7 +75,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
}
|
||||
}
|
||||
|
||||
protected void setFluid(@Nonnull FluidStack fluidStack)
|
||||
protected void setFluid(@NotNull FluidStack fluidStack)
|
||||
{
|
||||
if (fluidStack.isEmpty())
|
||||
container = new ItemStack(Items.BUCKET);
|
||||
@@ -92,7 +89,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack getFluidInTank(int tank) {
|
||||
|
||||
@@ -106,7 +103,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
|
||||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) {
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -127,7 +124,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
return FluidAttributes.BUCKET_VOLUME;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
||||
{
|
||||
@@ -149,7 +146,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@NotNull
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, FluidAction action)
|
||||
{
|
||||
@@ -170,10 +167,10 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
|
||||
|
||||
return FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
||||
@NotNull
|
||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nullable Direction facing)
|
||||
{
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY.orEmpty(capability, holder);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user