Skip to content

Commit

Permalink
Refactor cart/train APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm0keySa1m0n committed Sep 5, 2023
1 parent 051ad83 commit 70cd7e7
Show file tree
Hide file tree
Showing 71 changed files with 531 additions and 815 deletions.
68 changes: 0 additions & 68 deletions src/api/java/mods/railcraft/api/carts/CartUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ This work (the API) is licensed under the "MIT" License,
-----------------------------------------------------------------------------*/
package mods.railcraft.api.carts;

import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraftforge.fluids.FluidStack;

/**
* Replaces ILiquidTransfer with a simpler interface for moving Fluids between Minecarts.
* <p/>
*
* @see mods.railcraft.api.carts.TrainTransferService
* Allows minecarts to control fluid transfer behaviour through a train.
*/
public interface FluidMinecart {
public interface FluidTransferHandler {
/**
* This function controls whether a cart can pass push or pull requests. This function is only
* called if the cart cannot fulfill the request itself.
Expand All @@ -35,11 +31,11 @@ public interface FluidMinecart {
* <p/>
* If this interface is not implemented, it is assumed to be true.
*
* @param requester the AbstractMinecartEntity that initiated the action
* @param fluid the Fluid
* @param requester - the {@link RollingStock} that initiated the action
* @param fluid - the {@link FluidStack}
* @return true if cart will accept the fluid
*/
boolean canAcceptPushedFluid(AbstractMinecart requester, FluidStack fluid);
boolean canAcceptPushedFluid(RollingStock requester, FluidStack fluid);

/**
* This function controls whether a cart will fulfill a pull request for a specific Fluid. Even if
Expand All @@ -48,11 +44,11 @@ public interface FluidMinecart {
* <p/>
* If this interface is not implemented, it is assumed to be true.
*
* @param requester the AbstractMinecartEntity that initiated the action
* @param fluid the Fluid
* @param requester - the {@link RollingStock} that initiated the action
* @param fluid - the {@link FluidStack}
* @return true if the cart can provide the fluid
*/
boolean canProvidePulledFluid(AbstractMinecart requester, FluidStack fluid);
boolean canProvidePulledFluid(RollingStock requester, FluidStack fluid);

/**
* Set by the Liquid Loader while filling, primarily used for rendering a visible change while
Expand Down
23 changes: 7 additions & 16 deletions src/api/java/mods/railcraft/api/carts/ItemTransferHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@ This work (the API) is licensed under the "MIT" License,
-----------------------------------------------------------------------------*/
package mods.railcraft.api.carts;

import net.minecraft.world.entity.vehicle.AbstractMinecart;
import net.minecraft.world.item.ItemStack;

/**
* This class replaces IItemTransfer for controlling how items move through a train. It is entirely
* optional to implement this class, default values will be determined based on several factors.
*
* It is not required that every cart implementing this also has an inventory, but if you wish to
* accept or provide items you should implement Container or provide an IItemHandler capability.
*
* <p/>
*
* @see mods.railcraft.api.carts.TrainTransferService
* Allows minecarts to control item transfer behaviour through a train.
*/
public interface ItemTransferHandler {
/**
Expand All @@ -39,11 +30,11 @@ public interface ItemTransferHandler {
* <p/>
* If this interface is not implemented, it is assumed to be true.
*
* @param requester the AbstractMinecartEntity that initiated the action
* @param stack the ItemStack
* @param requester - the {@link RollingStock} that initiated the action
* @param stack - the {@link ItemStack}
* @return true if the cart can accept the item
*/
boolean canAcceptPushedItem(AbstractMinecart requester, ItemStack stack);
boolean canAcceptPushedItem(RollingStock requester, ItemStack stack);

/**
* This function controls whether a cart will fulfill a pull request for a specific item. Even if
Expand All @@ -52,9 +43,9 @@ public interface ItemTransferHandler {
* <p/>
* If this interface is not implemented, it is assumed to be true.
*
* @param requester the AbstractMinecartEntity that initiated the action
* @param stack the ItemStack
* @param requester - the {@link RollingStock} that initiated the action
* @param stack - the {@link ItemStack}
* @return true if the cart can provide the item
*/
boolean canProvidePulledItem(AbstractMinecart requester, ItemStack stack);
boolean canProvidePulledItem(RollingStock requester, ItemStack stack);
}

0 comments on commit 70cd7e7

Please sign in to comment.