Skip to content

Commit

Permalink
Transfer rewrite (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaMode committed Nov 12, 2023
1 parent 8d64ca2 commit 634111e
Show file tree
Hide file tree
Showing 35 changed files with 521 additions and 417 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ minecraft_range=[1.18.2,1.19)

# Fabric Version Information
# check these on https://fabricmc.net/versions.html
fabric_version=0.87.0+1.20.1
fabric_version=0.90.4+1.20.1
loader_version=0.14.21
# https://parchmentmc.org/docs/getting-started
parchment_version=2023.03.12

# Build Dependencies
mantle_version=1.9.254
port_lib_version = 2.1.1141
mantle_version=1.9.255
port_lib_version = 2.1.1152
mantle_range=[1.9.19,)
milk_lib_version=1.2.58
dripstone_fluid_lib_version=3.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementRewards;
import net.minecraft.advancements.CriterionTriggerInstance;
Expand Down Expand Up @@ -36,7 +39,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;
import slimeknights.mantle.data.GenericDataProvider;
import slimeknights.mantle.transfer.fluid.FluidTank;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.common.TinkerTags;
import slimeknights.tconstruct.common.json.ConfigEnabledCondition;
Expand Down Expand Up @@ -387,7 +389,7 @@ protected void generate() {
/** Gets a tank filled with the given fluid */
private static FluidTank getTankWith(Fluid fluid, long capacity) {
FluidTank tank = new FluidTank(capacity);
tank.fill(new FluidStack(fluid, capacity), false);
TransferUtil.insert(tank, FluidVariant.of(fluid), capacity);
return tank;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package slimeknights.tconstruct.library.client.model;

import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
import slimeknights.mantle.client.model.ModelProperty;
import slimeknights.mantle.transfer.fluid.FluidTank;

public class ModelProperties {
public static final ModelProperty<FluidTank> FLUID_TANK = new ModelProperty<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.github.fabricators_of_create.porting_lib.models.geometry.IGeometryLoader;
import io.github.fabricators_of_create.porting_lib.models.geometry.IUnbakedGeometry;
import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
Expand Down Expand Up @@ -43,7 +44,6 @@
import slimeknights.mantle.client.model.util.ColoredBlockModel;
import slimeknights.mantle.client.model.util.ExtraTextureConfiguration;
import slimeknights.mantle.client.model.util.SimpleBlockModel;
import slimeknights.mantle.transfer.fluid.FluidTank;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.common.config.Config;
import slimeknights.tconstruct.library.client.model.ModelProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package slimeknights.tconstruct.library.fluid;

import io.github.fabricators_of_create.porting_lib.transfer.fluid.FluidTank;
import net.minecraft.world.level.Level;
import slimeknights.mantle.block.entity.MantleBlockEntity;
import slimeknights.mantle.transfer.fluid.FluidTank;
import slimeknights.tconstruct.common.network.TinkerNetwork;
import slimeknights.tconstruct.smeltery.network.FluidUpdatePacket;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import io.github.fabricators_of_create.porting_lib.transfer.item.ItemHandlerHelper;
import io.netty.handler.codec.DecoderException;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.item.ItemStack;
import slimeknights.mantle.recipe.helper.ItemOutput;
import slimeknights.mantle.transfer.item.ItemHandlerHelper;

import java.util.Random;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package slimeknights.tconstruct.library.recipe.material;

import io.github.fabricators_of_create.porting_lib.transfer.item.ItemHandlerHelper;
import lombok.Getter;
import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -11,7 +12,6 @@
import slimeknights.mantle.recipe.ICustomOutputRecipe;
import slimeknights.mantle.recipe.container.ISingleStackContainer;
import slimeknights.mantle.recipe.helper.ItemOutput;
import slimeknights.mantle.transfer.item.ItemHandlerHelper;
import slimeknights.tconstruct.library.materials.MaterialRegistry;
import slimeknights.tconstruct.library.materials.definition.MaterialId;
import slimeknights.tconstruct.library.materials.definition.MaterialVariant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.google.gson.JsonObject;
import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
Expand Down Expand Up @@ -57,7 +60,7 @@ public FluidStack getOutput(IMeltingContainer inv) {
}

@Override
public void handleByproducts(IMeltingContainer inv, IFluidHandler handler) {
public void handleByproducts(IMeltingContainer inv, SlottedStorage<FluidVariant> handler) {
ItemStack input = inv.getStack();
int maxDamage = input.getMaxDamage();
if (maxDamage <= 0) {
Expand All @@ -67,7 +70,7 @@ public void handleByproducts(IMeltingContainer inv, IFluidHandler handler) {
int itemDamage = input.getDamageValue();
for (int i = 0; i < byproducts.size(); i++) {
FluidStack fluidStack = byproducts.get(i);
handler.fill(scaleOutput(fluidStack, itemDamage, maxDamage, i < byproductSizes.length ? byproductSizes[i] : unitSize), false);
TransferUtil.insertFluid(handler, scaleOutput(fluidStack, itemDamage, maxDamage, i < byproductSizes.length ? byproductSizes[i] : unitSize));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package slimeknights.tconstruct.library.recipe.melting;

import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import slimeknights.mantle.recipe.ICustomOutputRecipe;
Expand Down Expand Up @@ -39,7 +41,7 @@ public interface IMeltingRecipe extends ICustomOutputRecipe<IMeltingContainer> {
* @param inv Input inventory
* @param handler Fluid handler to fill with the byproduct
*/
default void handleByproducts(IMeltingContainer inv, IFluidHandler handler) {}
default void handleByproducts(IMeltingContainer inv, SlottedStorage<FluidVariant> handler) {}

/* Recipe data */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import io.github.fabricators_of_create.porting_lib.transfer.TransferUtil;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.minecraft.core.NonNullList;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -85,10 +88,10 @@ public OreRateType getOreType() {
}

@Override
public void handleByproducts(IMeltingContainer inv, IFluidHandler handler) {
public void handleByproducts(IMeltingContainer inv, SlottedStorage<FluidVariant> handler) {
// fill byproducts until we run out of space or byproducts
for (FluidStack fluidStack : byproducts) {
handler.fill(fluidStack.copy(), false);
TransferUtil.insertFluid(handler, fluidStack.copy());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
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.item.base.SingleStackStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
Expand All @@ -23,9 +22,6 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import slimeknights.mantle.transfer.item.IItemHandler;
import slimeknights.mantle.transfer.item.IItemHandlerModifiable;
import slimeknights.mantle.transfer.item.ItemHandlerHelper;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.common.TinkerTags;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
Expand Down Expand Up @@ -177,9 +173,9 @@ public static boolean isBlacklisted(ItemStack stack) {
}

@Override
public boolean isItemValid(int slot, ItemVariant stack) {
public boolean isItemValid(int slot, ItemVariant stack, int count) {
// no nesting item handlers
if (!stack.isBlank() && isBlacklisted(stack.toStack())) {
if (!stack.isBlank() && isBlacklisted(stack.toStack(count))) {
return false;
}
IToolStackView tool = this.tool.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@


import io.github.fabricators_of_create.porting_lib.block.CustomUpdateTagHandlingBlockEntity;
import io.github.fabricators_of_create.porting_lib.util.LazyOptional;
import lombok.Getter;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.SlottedStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.minecraft.core.BlockPos;
Expand All @@ -19,8 +20,6 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import slimeknights.mantle.transfer.fluid.IFluidHandler;
import slimeknights.mantle.transfer.item.IItemHandler;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.smeltery.TinkerSmeltery;
import slimeknights.tconstruct.smeltery.block.entity.component.SmelteryInputOutputBlockEntity.SmelteryFluidIO;
Expand Down Expand Up @@ -74,8 +73,8 @@ public Storage<ItemVariant> getItemStorage(@org.jetbrains.annotations.Nullable D
}

@Override
protected LazyOptional<IFluidHandler> makeWrapper(LazyOptional<IFluidHandler> capability) {
return LazyOptional.of(() -> new DuctTankWrapper(capability.orElse(emptyInstance), itemHandler));
protected Storage<FluidVariant> makeWrapper(SlottedStorage<FluidVariant> capability) {
return new DuctTankWrapper(capability, itemHandler);
}

/** Updates the fluid in model data */
Expand Down
Loading

0 comments on commit 634111e

Please sign in to comment.