Skip to content

Commit

Permalink
Some block entities (<500 errors to go)
Browse files Browse the repository at this point in the history
  • Loading branch information
Electro593 committed Jan 27, 2025
1 parent 97fb592 commit 402393e
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class PedestalBlockEntity extends LockableContainerBlockEntity implements
private static final int[] ACCESSIBLE_SLOTS_ADVANCED = {9, 10, 11, 12};
private static final int[] ACCESSIBLE_SLOTS_COMPLEX = {9, 10, 11, 12, 13};

protected final AutoCraftingInventory autoCraftingInventory;
protected UUID ownerUUID;
protected PedestalVariant pedestalVariant;
protected DefaultedList<ItemStack> inventory;
Expand Down Expand Up @@ -105,7 +104,6 @@ public PedestalBlockEntity(BlockPos blockPos, BlockState blockState) {
} else {
this.pedestalVariant = BuiltinPedestalVariant.BASIC_AMETHYST;
}
autoCraftingInventory = new AutoCraftingInventory(3, 3);

this.inventory = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
this.recipeInput = CraftingRecipeInput.create(3, 3, this.inventory);
Expand Down Expand Up @@ -321,8 +319,7 @@ public static void playCraftingFinishedSoundEvent(PedestalBlockEntity pedestalBl

// unchanged vanilla recipe?
if (SpectrumCommon.CONFIG.canPedestalCraftVanillaRecipes()) {
pedestalBlockEntity.autoCraftingInventory.setInputInventory(pedestalBlockEntity.inventory.subList(0, 9));
if (currentRecipe instanceof CraftingRecipe craftingRecipe && craftingRecipe.matches(pedestalBlockEntity.autoCraftingInventory, world)) {
if (currentRecipe instanceof CraftingRecipe craftingRecipe && craftingRecipe.matches(pedestalBlockEntity.recipeInput, world)) {
return pedestalBlockEntity.currentRecipe;
}
}
Expand All @@ -332,7 +329,7 @@ public static void playCraftingFinishedSoundEvent(PedestalBlockEntity pedestalBl
var pedestalRecipe = world.getRecipeManager().getFirstMatch(SpectrumRecipeTypes.PEDESTAL, pedestalBlockEntity.recipeInput, world).orElse(null);
if (pedestalRecipe == null) {
if (SpectrumCommon.CONFIG.canPedestalCraftVanillaRecipes()) {
return world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, pedestalBlockEntity.autoCraftingInventory, world).orElse(null);
return world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, pedestalBlockEntity.recipeInput, world).orElse(null);
}
return null;
}
Expand All @@ -349,8 +346,7 @@ private boolean canAcceptRecipeOutput(@Nullable Recipe<?> recipe, CraftingRecipe
if (recipe instanceof PedestalRecipe pedestalRecipe) {
output = pedestalRecipe.craft(input, null);
} else if (recipe instanceof CraftingRecipe craftingRecipe) {
autoCraftingInventory.setInputInventory(this, 0, 9);
output = craftingRecipe.craft(autoCraftingInventory, null);
output = craftingRecipe.craft(recipeInput, null);
} else {
output = ItemStack.EMPTY;
}
Expand Down Expand Up @@ -634,9 +630,7 @@ private void playSound(SoundEvent soundEvent) {

private boolean craftVanillaRecipe(@Nullable CraftingRecipe recipe, Inventory inventory, int maxCountPerStack) {
if (canAcceptRecipeOutput(recipe, recipeInput, maxCountPerStack)) {
autoCraftingInventory.setInputInventory(inventory, 0, 9);

ItemStack recipeOutput = recipe.craft(autoCraftingInventory, null);
ItemStack recipeOutput = recipe.craft(recipeInput, null);
PlayerEntity player = getOwnerIfOnline();
//TODO revise for non-player crafting
if (player != null) { // some recipes may assume the player is never null (since this is the case in vanilla)
Expand Down Expand Up @@ -795,8 +789,7 @@ public ItemStack getCurrentCraftingRecipeOutput() {
}

if (currentRecipe instanceof CraftingRecipe craftingRecipe) {
autoCraftingInventory.setInputInventory(this, 0, 9);
return craftingRecipe.craft(autoCraftingInventory, null);
return craftingRecipe.craft(recipeInput, null);
}

return ItemStack.EMPTY;
Expand Down
Loading

0 comments on commit 402393e

Please sign in to comment.