Skip to content

Commit

Permalink
Fix some 1.20.2 crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Jan 2, 2024
1 parent c3b9554 commit 4894bd6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void handledScreenTick() {
this.isActive = handler.isActive;
DefaultedList<ItemStack> inventory = DefaultedList.ofSize(1,handler.getInventory().getStack(0));
Optional<RecipeEntry<SmokingRecipe>> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void clearCraftingSlots() {

@Override
public boolean matches(RecipeEntry<? extends Recipe<Inventory>> 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
Expand Down Expand Up @@ -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<? extends AbstractCookingRecipe> entry = this.world.getRecipeManager().getFirstMatch(this.recipeType, new SimpleInventory(itemStack), this.world).orElseGet(null);
return entry != null && entry.value() != null;
}

public int getCookProgress() {
Expand Down

0 comments on commit 4894bd6

Please sign in to comment.