Skip to content

Commit

Permalink
Merge pull request #6 from TonimatasMCDEV/1.19/fixes
Browse files Browse the repository at this point in the history
Delete unnecessary lines
  • Loading branch information
TonimatasDEV authored Jul 13, 2022
2 parents d8e194a + 11180c5 commit c32e623
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.tonimatasmc.krystalcraft.block.entity.Utils;

import net.minecraft.world.SimpleContainer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraftforge.items.ItemStackHandler;
import net.tonimatasmc.krystalcraft.item.ModItems;

public class Simplify {
public static boolean hasWaterInWaterSlot(ItemStackHandler itemStackHandler) {
return itemStackHandler.getStackInSlot(0).getItem() == ModItems.SET_WATER_BOTTLES.get();
}

public static boolean hasCoalSlot(ItemStackHandler itemStackHandler, int fuelProgress, int fuelMaxProgress) {
return itemStackHandler.getStackInSlot(2).getItem() == Items.COAL || fuelProgress <= fuelMaxProgress;
}

public static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) {
return inventory.getItem(3).getItem() == output.getItem() || inventory.getItem(3).isEmpty();
}

public static boolean canInsertAmountIntoOutputSlot(SimpleContainer inventory) {
return inventory.getItem(3).getMaxStackSize() > inventory.getItem(3).getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.tonimatasmc.krystalcraft.block.entity.ModBlockEntities;
import net.tonimatasmc.krystalcraft.block.entity.Utils.Simplify;
import net.tonimatasmc.krystalcraft.recipe.CoalCombinerRecipe;
import net.tonimatasmc.krystalcraft.screen.CoalCombinerMenu;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -159,7 +160,7 @@ private static boolean hasRecipe(CoalCombinerBlockEntity entity) {

Optional<CoalCombinerRecipe> match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(CoalCombinerRecipe.Type.INSTANCE, inventory, level);

return match.isPresent() && canInsertAmountIntoOutputSlot(inventory) && canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && hasCoalSlot(entity);
return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && hasCoalSlot(entity);

}

Expand Down Expand Up @@ -190,12 +191,4 @@ private static void craftItem(CoalCombinerBlockEntity entity) {
private void resetProgress() {
this.progress = 0;
}

private static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) {
return inventory.getItem(3).getItem() == output.getItem() || inventory.getItem(3).isEmpty();
}

private static boolean canInsertAmountIntoOutputSlot(SimpleContainer inventory) {
return inventory.getItem(3).getMaxStackSize() > inventory.getItem(3).getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.tonimatasmc.krystalcraft.block.entity.ModBlockEntities;
import net.tonimatasmc.krystalcraft.block.entity.Utils.Simplify;
import net.tonimatasmc.krystalcraft.item.ModItems;
import net.tonimatasmc.krystalcraft.recipe.GemCuttingStationRecipe;
import net.tonimatasmc.krystalcraft.screen.GemCuttingStationMenu;
Expand Down Expand Up @@ -154,7 +155,7 @@ private static boolean hasRecipe(GemCuttingStationBlockEntity entity) {
Optional<GemCuttingStationRecipe> match = Objects.requireNonNull(level).getRecipeManager()
.getRecipeFor(GemCuttingStationRecipe.Type.INSTANCE, inventory, level);

return match.isPresent() && canInsertAmountIntoOutputSlot(inventory) && canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) &&
return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) &&
hasWaterInWaterSlot(entity) && hasToolsInToolSlot(entity);
}

Expand Down Expand Up @@ -201,12 +202,4 @@ private static void craftItem(GemCuttingStationBlockEntity entity) {
private void resetProgress() {
this.progress = 0;
}

private static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) {
return inventory.getItem(3).getItem() == output.getItem() || inventory.getItem(3).isEmpty();
}

private static boolean canInsertAmountIntoOutputSlot(SimpleContainer inventory) {
return inventory.getItem(3).getMaxStackSize() > inventory.getItem(3).getCount();
}
}

0 comments on commit c32e623

Please sign in to comment.