diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/blockentities/StovetopBlockEntity.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/blockentities/StovetopBlockEntity.java index 45604166f..7b0d80dcc 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/blockentities/StovetopBlockEntity.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/blockentities/StovetopBlockEntity.java @@ -44,10 +44,9 @@ public static void litServerTick(World world, BlockPos pos, BlockState state, St ItemStack itemStack = stovetopBlockEntity.itemsBeingCooked.get(i); if (itemStack.isEmpty()) continue; bl = true; - int n = i; - if (stovetopBlockEntity.cookingTimes[n] < 600){ - stovetopBlockEntity.cookingTimes[n] = stovetopBlockEntity.cookingTimes[n] + 2; - } + if (stovetopBlockEntity.cookingTimes[i] < 600){ + stovetopBlockEntity.cookingTimes[i] = stovetopBlockEntity.cookingTimes[i] + 2; + } if (stovetopBlockEntity.cookingTimes[i] < stovetopBlockEntity.cookingTotalTimes[i]) continue; SimpleInventory inventory = new SimpleInventory(itemStack); ItemStack itemStack2 = world.getRecipeManager().getFirstMatch(RecipeType.CAMPFIRE_COOKING, inventory, world).map(campfireCookingRecipe -> campfireCookingRecipe.value().craft(inventory, world.getRegistryManager())).orElse(itemStack); diff --git a/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java b/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java index 6c5a9a64d..b65eabb1b 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java +++ b/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java @@ -88,7 +88,7 @@ protected void handledScreenTick() { this.isActive = handler.isActive; DefaultedList inventory = DefaultedList.ofSize(1,handler.getInventory().getStack(0)); Optional> recipe = getRecipe(handler.microwaveBlockEntity.getWorld(), handler.getInventory()); - if(recipe.isPresent() && microwaveBlockEntity.getWorld() != null && !MicrowaveBlockEntity.canAcceptRecipeOutput(microwaveBlockEntity.getWorld().getRegistryManager(), recipe.get().value(), inventory ,microwaveBlockEntity.getMaxCountPerStack()) && !this.handler.isActive()) { + if(recipe.isPresent() && microwaveBlockEntity.getWorld() != null && !MicrowaveBlockEntity.canAcceptRecipeOutput(microwaveBlockEntity.getWorld().getRegistryManager(), recipe.get() != null ? recipe.get().value() : null, inventory ,microwaveBlockEntity.getMaxCountPerStack()) && !this.handler.isActive()) { this.startButton.active = false; } else { diff --git a/common/src/main/java/com/unlikepaladin/pfm/entity/render/MicrowaveBlockEntityRenderer.java b/common/src/main/java/com/unlikepaladin/pfm/entity/render/MicrowaveBlockEntityRenderer.java index a6125d9e3..881487fbd 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/entity/render/MicrowaveBlockEntityRenderer.java +++ b/common/src/main/java/com/unlikepaladin/pfm/entity/render/MicrowaveBlockEntityRenderer.java @@ -57,7 +57,7 @@ public void render(T blockEntity, float tickDelta, MatrixStack matrices, VertexC } matrices.translate(x, y ,z); matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-facing.asRotation())); - if (blockEntity.isActive && MicrowaveBlockEntity.canAcceptRecipeOutput(blockEntity.getWorld().getRegistryManager(),blockEntity.getRecipe().value(), blockEntity.inventory ,blockEntity.getMaxCountPerStack())) { + if (blockEntity.isActive && blockEntity.getRecipe() != null && blockEntity.getRecipe().value() != null && MicrowaveBlockEntity.canAcceptRecipeOutput(blockEntity.getWorld().getRegistryManager(),blockEntity.getRecipe().value(), blockEntity.inventory ,blockEntity.getMaxCountPerStack())) { matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((blockEntity.getWorld().getTime() + tickDelta) * 4));} matrices.scale(0.5f, 0.5f, 0.5f); this.itemRenderer.renderItem(itemStack, ModelTransformationMode.GROUND, lightAbove, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0); diff --git a/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java b/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java index 9b82caee0..c36f028c8 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java +++ b/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java @@ -84,7 +84,7 @@ public void clearCraftingSlots() { @Override public boolean matches(RecipeEntry> recipe) { - return recipe != null && recipe.value().matches(this.inventory, this.world); + return recipe != null && recipe.value() != null && recipe.value().matches(this.inventory, this.world); } @Override @@ -173,7 +173,8 @@ protected boolean insertItemToSlot(ItemStack stack, int startIndex, int endIndex } protected boolean isCookable(ItemStack itemStack) { - return this.world.getRecipeManager().getFirstMatch(this.recipeType, new SimpleInventory(itemStack), this.world).isPresent(); + RecipeEntry entry = this.world.getRecipeManager().getFirstMatch(this.recipeType, new SimpleInventory(itemStack), this.world).orElseGet(null); + return entry != null && entry.value() != null; } public int getCookProgress() {