Skip to content

Commit

Permalink
work on crystal growth chamber
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjectET committed Oct 16, 2023
1 parent 542c666 commit f85a13c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BECrystalGrowth extends AENetworkPowerBlockEntity implements IGridT
private final CombinedInternalInventory combInv = new CombinedInternalInventory(topRow, midRow, botRow);

private final Map<AppEngInternalInventory, Integer> progress = new IdentityHashMap<>(Map.of(topRow, 0, midRow, 0, botRow, 0));
private final Map<AppEngInternalInventory, CrystalGrowthRecipe> cachedRecipes = new IdentityHashMap<>();
private final Map<AppEngInternalInventory, CrystalGrowthRecipe> cachedRecipes = new WeakHashMap<>();

private IUpgradeInventory upgrades;

Expand All @@ -62,7 +62,6 @@ public class BECrystalGrowth extends AENetworkPowerBlockEntity implements IGridT
public BECrystalGrowth(BlockPos pos, BlockState state) {
super(AE2Things.CRYSTAL_GROWTH_BE, pos, state);
upgrades = UpgradeInventories.forMachine(AE2Things.CRYSTAL_GROWTH, 3, this::saveChanges);

var filter = new FilteredInventory();
this.extInventory = new FilteredInternalInventory(combInv, filter);

Expand Down Expand Up @@ -325,7 +324,7 @@ public boolean allowExtract(InternalInventory inv, int slot, int amount) {

@Override
public boolean allowInsert(InternalInventory inv, int slot, ItemStack stack) {
return !(slot == 3);
return !(slot == 3) && CrystalGrowthRecipe.getRecipefromStack(getLevel(), stack) != null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public CrystalGrowthRecipe(ResourceLocation id, Ingredient flawlessCrystal, Ingr
this.outputIngredient = outputIngredient;
}

public static Iterable<CrystalGrowthRecipe> getRecipes(Level level) {
return level.getRecipeManager().getAllRecipesFor(CrystalGrowthRecipe.TYPE);
}

public static CrystalGrowthRecipe getRecipefromStack(Level level, ItemStack item) {
Collection<CrystalGrowthRecipe> values = level.getRecipeManager().getAllRecipesFor(CrystalGrowthRecipe.TYPE);
CrystalGrowthRecipe matchedRecipe = null;
for (CrystalGrowthRecipe recipe : values) {
for (CrystalGrowthRecipe recipe : getRecipes(level)) {
for(Ingredient ingredient : recipe.getIngredients()) {
if(ingredient.test(item))
matchedRecipe = recipe;
Expand Down

0 comments on commit f85a13c

Please sign in to comment.