Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 10, 2024
2 parents ced9fb2 + ad4213a commit 7d82545
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
7 changes: 7 additions & 0 deletions resources/changelog/1.19.2-2.9.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.17.0 or higher.

Fixes:
* Fix Vanilla Furnace not accepting recipes with some empty inputs
Closes CyclopsMC/IntegratedDynamics#1432

7 changes: 7 additions & 0 deletions resources/changelog/1.20.1-2.9.4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.18.4 or higher.

Fixes:
* Fix Vanilla Furnace not accepting recipes with some empty inputs
Closes CyclopsMC/IntegratedDynamics#1432

Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public ICapabilityProvider<FurnaceBlockEntity, Direction, IRecipeHandler> createProvider(BlockEntityType<FurnaceBlockEntity> capabilityKey) {
return (blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(blockEntity::getLevel,
RecipeType.SMELTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)));
RecipeType.SMELTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)), true);
}
});
registry.registerBlockEntity(() -> BlockEntityType.BLAST_FURNACE,
Expand All @@ -455,7 +455,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public ICapabilityProvider<BlastFurnaceBlockEntity, Direction, IRecipeHandler> createProvider(BlockEntityType<BlastFurnaceBlockEntity> capabilityKey) {
return (blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(blockEntity::getLevel,
RecipeType.BLASTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)));
RecipeType.BLASTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)), true);
}
});
registry.registerBlockEntity(() -> BlockEntityType.SMOKER,
Expand All @@ -468,7 +468,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public ICapabilityProvider<SmokerBlockEntity, Direction, IRecipeHandler> createProvider(BlockEntityType<SmokerBlockEntity> capabilityKey) {
return (blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(blockEntity::getLevel,
RecipeType.SMOKING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)));
RecipeType.SMOKING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)), true);
}
});
registry.registerBlockEntity(() -> BlockEntityType.CAMPFIRE,
Expand All @@ -481,7 +481,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public ICapabilityProvider<CampfireBlockEntity, Direction, IRecipeHandler> createProvider(BlockEntityType<CampfireBlockEntity> capabilityKey) {
return (blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(blockEntity::getLevel,
RecipeType.CAMPFIRE_COOKING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)));
RecipeType.CAMPFIRE_COOKING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)), true);
}
});
registry.registerInheritableBlock(CraftingTableBlock.class,
Expand All @@ -494,7 +494,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public IBlockCapabilityProvider<IRecipeHandler, Direction> createProvider(Block capabilityKey) {
return (level, pos, state, blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(() -> level,
RecipeType.CRAFTING, (size) -> size > 0, CraftingContainer::asCraftInput);
RecipeType.CRAFTING, (size) -> size > 0, CraftingContainer::asCraftInput, false);
}
});
registry.registerBlock(() -> (StonecutterBlock) Blocks.STONECUTTER,
Expand All @@ -507,7 +507,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public IBlockCapabilityProvider<IRecipeHandler, Direction> createProvider(StonecutterBlock capabilityKey) {
return (level, pos, state, blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(() -> level,
RecipeType.STONECUTTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)));
RecipeType.STONECUTTING, (size) -> size == 1, (c) -> new SingleRecipeInput(c.getItem(0)), true);
}
});
registry.registerBlock(() -> (SmithingTableBlock) Blocks.SMITHING_TABLE,
Expand All @@ -520,7 +520,7 @@ public BaseCapability<IRecipeHandler, Direction> getCapability() {
@Override
public IBlockCapabilityProvider<IRecipeHandler, Direction> createProvider(SmithingTableBlock capabilityKey) {
return (level, pos, state, blockEntity, side) -> new VanillaRecipeTypeRecipeHandler<>(() -> level,
RecipeType.SMITHING, (size) -> size == 1, (c) -> new SmithingRecipeInput(c.getItem(0), c.getItem(1), c.getItem(2)));
RecipeType.SMITHING, (size) -> size == 1, (c) -> new SmithingRecipeInput(c.getItem(0), c.getItem(1), c.getItem(2)), true);
}
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public boolean stillValid(Player playerIn) {
private final RecipeType<T> recipeType;
private final Predicate<Integer> inputSizePredicate;
private final Function<CraftingContainer, C> createRecipeInput;
private final boolean ignoreEmptySlots;

private static Map<Pair<RecipeType<?>, ResourceLocation>, Collection<IRecipeDefinition>> CACHED_RECIPES = Maps.newHashMap();

public VanillaRecipeTypeRecipeHandler(Supplier<Level> worldSupplier, RecipeType<T> recipeType, Predicate<Integer> inputSizePredicate, Function<CraftingContainer, C> createRecipeInput) {
public VanillaRecipeTypeRecipeHandler(Supplier<Level> worldSupplier, RecipeType<T> recipeType, Predicate<Integer> inputSizePredicate, Function<CraftingContainer, C> createRecipeInput, boolean ignoreEmptySlots) {
this.worldSupplier = worldSupplier;
this.recipeType = recipeType;
this.inputSizePredicate = inputSizePredicate;
this.createRecipeInput = createRecipeInput;
this.ignoreEmptySlots = ignoreEmptySlots;
}

@Override
Expand Down Expand Up @@ -153,7 +155,10 @@ public Collection<IRecipeDefinition> getRecipes() {
@Override
public IMixedIngredients simulate(IMixedIngredients input) {
List<ItemStack> recipeIngredients = input.getInstances(IngredientComponent.ITEMSTACK);
if (input.getComponents().size() != 1 || recipeIngredients.size() < 1) {
if (this.ignoreEmptySlots) {
recipeIngredients = recipeIngredients.stream().filter(itemStack -> !itemStack.isEmpty()).toList();
}
if (input.getComponents().size() != 1 || recipeIngredients.isEmpty()) {
return null;
}

Expand Down

0 comments on commit 7d82545

Please sign in to comment.