Skip to content

Commit

Permalink
even more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lordIcocain committed Dec 14, 2024
1 parent 837ad2f commit b3246c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/main/java/gregtech/api/logic/ProcessingLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ public GTRecipe getRecipeByInputs(ItemStack[] inItems, FluidStack[] inFluids) {
return map.findRecipeQuery()
.items(inItems)
.fluids(inFluids)
.specialSlot(specialSlotItem)
.find();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public abstract class MTEMultiBlockBase extends MetaTileEntity
protected static final String VOID_EXCESS_NBT_KEY = "voidExcess";
protected static final String VOIDING_MODE_NBT_KEY = "voidingMode";
protected static final String BATCH_MODE_NBT_KEY = "batchMode";
protected static final String SUPER_CRIBS_MODE_NBT_KEY = "superCribsMode";
protected SingleRecipeCheck mSingleRecipeCheck = null;

public ArrayList<MTEHatchInput> mInputHatches = new ArrayList<>();
Expand Down Expand Up @@ -894,7 +893,7 @@ protected CheckRecipeResult doCheckRecipe() {

if (!slot.isEmpty()) {
if (!processingLogic.cribsHasRecipe(slotHash)
&& !processingLogic.setCribsSlotRecipe(slot.getPatternInputs(sharedItems), slotHash)) continue;
&& !processingLogic.setCribsSlotRecipe(slot.getPatternInputs(), slotHash)) continue;

processingLogic.setInputItems(ArrayUtils.addAll(sharedItems, slot.getItemInputs()));
processingLogic.setInputFluids(slot.getFluidInputs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public interface IDualInputInventory {

FluidStack[] getFluidInputs();

GTDualInputs getPatternInputs(ItemStack[] sharedItems);
GTDualInputs getPatternInputs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,33 @@ public class MTEHatchCraftingInputME extends MTEHatchInputBus
// Each pattern slot in the crafting input hatch has its own internal inventory
public static class PatternSlot implements IDualInputInventory {

public interface SharedItemGetter {

ItemStack[] getSharedItem();
}

private final ItemStack pattern;
private final ICraftingPatternDetails patternDetails;
private final List<ItemStack> itemInventory;
private final List<FluidStack> fluidInventory;
private final SharedItemGetter sharedItemGetter;

public PatternSlot(ItemStack pattern, World world) {
public PatternSlot(ItemStack pattern, World world, SharedItemGetter getter) {
this.pattern = pattern;
this.patternDetails = ((ICraftingPatternItem) Objects.requireNonNull(pattern.getItem()))
.getPatternForItem(pattern, world);
this.itemInventory = new ArrayList<>();
this.fluidInventory = new ArrayList<>();
this.sharedItemGetter = getter;
}

public PatternSlot(ItemStack pattern, NBTTagCompound nbt, World world) {
public PatternSlot(ItemStack pattern, NBTTagCompound nbt, World world, SharedItemGetter getter) {
this.pattern = pattern;
this.patternDetails = ((ICraftingPatternItem) Objects.requireNonNull(pattern.getItem()))
.getPatternForItem(pattern, world);
this.itemInventory = new ArrayList<>();
this.fluidInventory = new ArrayList<>();
this.sharedItemGetter = getter;
NBTTagList inv = nbt.getTagList("inventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < inv.tagCount(); i++) {
NBTTagCompound tagItemStack = inv.getCompoundTagAt(i);
Expand Down Expand Up @@ -210,10 +218,10 @@ public ICraftingPatternDetails getPatternDetails() {
return patternDetails;
}

public GTDualInputs getPatternInputs(ItemStack[] sharedItems) {
public GTDualInputs getPatternInputs() {
GTDualInputs dualInputs = new GTDualInputs();

ItemStack[] inputItems = sharedItems;
ItemStack[] inputItems = this.sharedItemGetter.getSharedItem();
FluidStack[] inputFluids = new FluidStack[0];

for (IAEItemStack singleInput : this.getPatternDetails()
Expand Down Expand Up @@ -579,7 +587,8 @@ public void loadNBTData(NBTTagCompound aNBT) {
internalInventory[patternSlot] = new PatternSlot(
pattern,
patternSlotNBT,
getBaseMetaTileEntity().getWorld());
getBaseMetaTileEntity().getWorld(),
this::getSharedItems);
} else {
GTMod.GT_FML_LOGGER.warn(
"An error occurred while loading contents of ME Crafting Input Bus. This pattern has been voided: "
Expand Down Expand Up @@ -801,7 +810,7 @@ private void onPatternChange(int index, ItemStack newItem) {
// original does not exist or has changed
if (newItem == null || !(newItem.getItem() instanceof ICraftingPatternItem)) return;

PatternSlot patternSlot = new PatternSlot(newItem, world);
PatternSlot patternSlot = new PatternSlot(newItem, world, this::getSharedItems);
internalInventory[index] = patternSlot;
patternDetailsPatternSlotMap.put(patternSlot.getPatternDetails(), patternSlot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ protected CheckRecipeResult doCheckRecipe() {

if (!slot.isEmpty()) {
if (!processingLogic.cribsHasRecipe(slotHash)
&& !processingLogic.setCribsSlotRecipe(slot.getPatternInputs(sharedItems), slotHash)) continue;
&& !processingLogic.setCribsSlotRecipe(slot.getPatternInputs(), slotHash)) continue;

processingLogic.setInputItems(ArrayUtils.addAll(sharedItems, slot.getItemInputs()));
processingLogic.setInputFluids(slot.getFluidInputs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ public GTRecipe getRecipeByInputs(ItemStack[] inItems, FluidStack[] inFluids) {
return map.findRecipeQuery()
.items(inItems)
.fluids(inFluids)
.specialSlot(specialSlotItem)
.find();
}

Expand Down

0 comments on commit b3246c6

Please sign in to comment.