Skip to content

Commit

Permalink
Update recycling recipe defaults to return scaling.
Browse files Browse the repository at this point in the history
  • Loading branch information
voidsong-dragonfly committed Jun 20, 2024
1 parent 4b26e72 commit 171e9e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ public ItemStack get()
);
return cachedStack;
}

public static TagOutput newWithAmount(TagOutput input, int amount) {
return new TagOutput(input.get().copyWithCount(amount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import net.minecraft.Util;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.items.ItemHandlerHelper;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
Expand Down Expand Up @@ -49,8 +51,7 @@ public ArcRecyclingRecipe(Supplier<RegistryAccess> tags, List<Pair<TagOutput, Do
this.defaultOutputs = Util.make(() -> {
List<TagOutput> ret = new ArrayList<>();
for(Pair<TagOutput, Double> e : outputs)
// TODO scaling?
ret.add(e.getFirst());
addTagOutputToList(ret, e);
return new TagOutputList(ret);
});
}
Expand Down Expand Up @@ -104,6 +105,24 @@ private void addOutputToList(double scaledOut, NonNullList<ItemStack> outs, Pair
}
}

private void addTagOutputToList(@Nonnull List<TagOutput> outs, Pair<TagOutput, Double> e)
{
//Noone likes nuggets anyway >_>
if(e.getSecond() >= 1)
outs.add(TagOutput.newWithAmount(e.getFirst(), (int)e.getSecond().doubleValue()));
int nuggetOut = (int)((e.getSecond()-(int)e.getSecond().doubleValue())*9);
if(nuggetOut > 0)
{
String[] type = TagUtils.getMatchingPrefixAndRemaining(tags.get(), e.getFirst().get(), "ingots");
if(type!=null)
{
ItemStack nuggets = IEApi.getPreferredTagStack(tags.get(), TagUtils.createItemWrapper(IETags.getNugget(type[1])));
if(!nuggets.isEmpty())
outs.add(new TagOutput(nuggets.copyWithCount(nuggetOut)));
}
}
}

@Override
public boolean matches(ItemStack input, NonNullList<ItemStack> additives)
{
Expand Down

0 comments on commit 171e9e0

Please sign in to comment.