Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
update CEu to 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarri6343 committed Aug 13, 2022
1 parent a5d2777 commit fca5b1f
Show file tree
Hide file tree
Showing 14 changed files with 1,206 additions and 452 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ dependencies {

compile 'CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.673'
compile 'curse.maven:had-enough-items-557549:3766122'
deobfCompile 'curse.maven:gregtech-ce-unofficial-557242:3805253'
//deobfCompile 'curse.maven:gregtech-ce-unofficial-557242:3805253'
deobfCompile 'curse.maven:codechicken-lib-1-8-242818:2779848'
deobfCompile 'curse.maven:the-one-probe-245211:2667280'
deobfCompile 'curse.maven:ctm-267602:2915363'
compile (files("etc/modularui-1.0.jar"))

provided (files("libs/gregtech-1.12.2-2.3.4-beta.jar"))
}

sourceSets {
Expand Down
Binary file added libs/gregtech-1.12.2-2.3.4-beta.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -120,69 +120,17 @@ protected FluidTankList createExportFluidHandler() {

protected boolean canInputFluid(FluidStack inputFluid) {
ClayRecipeMap<?> recipeMap = workable.getRecipeMap();
if (recipeMap.canInputFluidForce(inputFluid.getFluid())) {
return true; // RecipeMap forces input
}
Collection<ClayRecipe> inputCapableRecipes = recipeMap.getRecipesForFluid(inputFluid);
if (inputCapableRecipes.isEmpty()) {
// Fluid cannot be inputted anyway, short-circuit and inform that the fluid cannot be inputted
return false;
}
boolean hasEmpty = false;
Collection<FluidKey> fluids = null;
for (IFluidTank fluidTank : importFluids) {
FluidStack fluidInTank = fluidTank.getFluid();
if (fluidInTank != null) {
if (inputFluid.isFluidEqual(fluidInTank)) {
// Both fluids are equal, short-circuit and inform that the fluid can be inputted
List<FluidStack> fluidInputs = new ArrayList<>();
for (IFluidTank fluidTank : this.importFluids.getFluidTanks()) {
FluidStack fluidStack = fluidTank.getFluid();
if (fluidStack != null && fluidStack.amount > 0){
if (fluidStack.isFluidEqual(inputFluid)) {
return true;
} else {
if (fluids == null) {
// Avoid object allocation + array expansion as this is a hotspot
if (fluidKeyCache == null) {
fluids = new ObjectArraySet<>(new FluidKey[] { new FluidKey(fluidInTank) });
} else {
fluidKeyCache.clear();
fluids = fluidKeyCache;
}
} else {
fluids.add(new FluidKey(fluidInTank));
}
}
} else {
hasEmpty = true;
}
}
if (!hasEmpty) {
// No empty slots to fill input in, inform that the fluid cannot be inputted
return false;
}
if (fluids == null) {
// There are empty slots to fill, and there are no other fluids, inform that the fluid can be inputted
return true;
}
for (FluidKey fluidKey : fluids) {
Collection<ClayRecipe> iter = recipeMap.getRecipesForFluid(fluidKey);
Collection<ClayRecipe> check;
// Iterate with the smaller collection as base
if (iter.size() > inputCapableRecipes.size()) {
check = iter;
iter = inputCapableRecipes;
} else {
check = inputCapableRecipes;
}
for (ClayRecipe it : iter) {
for (ClayRecipe ch : check) {
// Check identity equality, fast-track instead of doing Recipe#equals' tedious checks
if (it == ch) {
// Recipe exists in both collections, inform that the fluid can be inputted
return true;
}
}
fluidInputs.add(fluidStack);
}
}
// Ultimatum
return false;
return recipeMap != null && recipeMap.acceptsFluid(fluidInputs, inputFluid);
}

@Override
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/clayium/api/recipes/ClayRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import gregtech.api.GTValues;
import gregtech.api.capability.IMultipleTankHandler;
import gregtech.api.recipes.*;
import gregtech.api.recipes.ingredients.GTRecipeInput;
import gregtech.api.recipes.recipeproperties.IRecipePropertyStorage;
import gregtech.api.recipes.recipeproperties.RecipeProperty;
import gregtech.api.recipes.recipeproperties.RecipePropertyStorage;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -34,8 +36,8 @@ public class ClayRecipe extends Recipe {

private final int tier;

public ClayRecipe(List<CountableIngredient> inputs, List<ItemStack> outputs, List<ChanceEntry> chancedOutputs, List<FluidStack> fluidInputs, List<FluidStack> fluidOutputs, int duration, int EUt, boolean hidden, boolean isCTRecipe, int tier) {
super(inputs, outputs, chancedOutputs, fluidInputs, fluidOutputs, duration, EUt, hidden, isCTRecipe);
public ClayRecipe(List<GTRecipeInput> inputs, List<ItemStack> outputs, List<ChanceEntry> chancedOutputs, List<GTRecipeInput> fluidInputs, List<FluidStack> fluidOutputs, int duration, int EUt, boolean hidden, boolean isCTRecipe, IRecipePropertyStorage recipePropertyStorage, int tier) {
super(inputs, outputs, chancedOutputs, fluidInputs, fluidOutputs, duration, EUt, hidden, isCTRecipe, recipePropertyStorage);
this.tier = tier;
}

Expand Down Expand Up @@ -63,17 +65,8 @@ public List<ItemStack> getResultItemOutputs(int tier, ClayRecipeMap<?> recipeMap
}

public ClayRecipe copy() {
ClayRecipe newRecipe = new ClayRecipe(getInputs(), getOutputs(), getChancedOutputs(), getFluidInputs(), getFluidOutputs(), getDuration(), getEUt(), isHidden(), getIsCTRecipe(), getTier());
if (getRecipePropertyStorage().getSize() > 0) {
Iterator var2 = this.getRecipePropertyStorage().getRecipeProperties().iterator();

while(var2.hasNext()) {
Map.Entry<RecipeProperty<?>, Object> property = (Map.Entry)var2.next();
newRecipe.setProperty((RecipeProperty)property.getKey(), property.getValue());
}
}

return newRecipe;
return new ClayRecipe(getInputs(), getOutputs(), getChancedOutputs(), getFluidInputs(),
getFluidOutputs(), getDuration(), getEUt(), isHidden(), getIsCTRecipe(), getRecipePropertyStorage(), getTier());
}

public ClayRecipe trimRecipeOutputs(ClayRecipe currentRecipe, ClayRecipeMap<?> recipeMap, int itemTrimLimit, int fluidTrimLimit) {
Expand Down
Loading

0 comments on commit fca5b1f

Please sign in to comment.