Skip to content

Commit

Permalink
Merge branch 'releases/1.20.1' into Depository
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Apr 5, 2024
2 parents 7a3666a + 2f2ef61 commit 6894627
Show file tree
Hide file tree
Showing 22 changed files with 874 additions and 604 deletions.
324 changes: 0 additions & 324 deletions common/src/main/java/dev/dubhe/anvilcraft/api/log/Logger.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
import java.util.Optional;
import java.util.function.Predicate;

@Getter
@SuppressWarnings("NullableProblems")
public class AutoCrafterBlockEntity extends BaseMachineBlockEntity implements CraftingContainer, IFilterBlockEntity {
@Getter
@Setter
private boolean record = false;
@Getter
private final NonNullList<Boolean> disabled = this.getNewDisabled();
@Getter
private final NonNullList<@Unmodifiable ItemStack> filter = this.getNewFilter();
private static int levelHash = 1;
private static NonNullList<ItemStack> remainingItemsCache;
private final Deque<AutoCrafterCache> cache = new ArrayDeque<>();

public AutoCrafterBlockEntity(BlockPos pos, BlockState blockState) {
Expand Down Expand Up @@ -91,7 +93,10 @@ private static void craft(@NotNull Level level, @NotNull AutoCrafterBlockEntity
}
}
if (optional.isEmpty()) return;
NonNullList<ItemStack> nonNullList = level.getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, entity, level);
if (level.hashCode() != levelHash) {
levelHash = level.hashCode();
remainingItemsCache = level.getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, entity, level);
}
itemStack = optional.get().assemble(entity, level.registryAccess());
if (!itemStack.isItemEnabled(level.enabledFeatures())) return;
Container result = new SimpleContainer(1);
Expand All @@ -107,10 +112,12 @@ private static void craft(@NotNull Level level, @NotNull AutoCrafterBlockEntity
stack.shrink(1);
entity.setItem(i, stack);
}
Container container1 = new SimpleContainer(nonNullList.size());
for (int i = 0; i < nonNullList.size(); i++) container1.setItem(i, nonNullList.get(i));
for (int i = 0; i < nonNullList.size(); i++) {
entity.outputItem(itemDepository, direction, level, pos, container1, i, true, true, true, false);
Container container1 = new SimpleContainer(remainingItemsCache.size());
for (int i = 0; i < remainingItemsCache.size(); i++) {
container1.setItem(i, remainingItemsCache.get(i));
}
for (int i = 0; i < remainingItemsCache.size(); i++) {
entity.outputItem(itemDepository,entity.getDirection(), level, entity.getBlockPos(), container1, i, true, true, true, false);
}
level.updateNeighborsAt(pos, ModBlocks.AUTO_CRAFTER.get());
}
Expand Down
Loading

0 comments on commit 6894627

Please sign in to comment.