Skip to content

Commit

Permalink
Allow coal in the blast furnace
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Sep 20, 2023
1 parent 2aef923 commit 8bb4a4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BlastFurnaceMenu(int id, Inventory inventory, BlastFurnaceBlockEntity bla

var logic = blastFurnace.getBlastFurnaceModule();
this.addSlot(new RailcraftSlot(this.module, BlastFurnaceModule.SLOT_INPUT, 56, 17));
this.addSlot(new ItemFilterSlot(item -> logic.getItemBurnTime(item) > 0, this.module,
this.addSlot(new ItemFilterSlot(logic::isFuel, this.module,
BlastFurnaceModule.SLOT_FUEL, 56, 53));
this.addSlot(new OutputSlot(this.module, BlastFurnaceModule.SLOT_OUTPUT, 116, 21));
this.addSlot(new OutputSlot(this.module, BlastFurnaceModule.SLOT_SLAG, 116, 53));
Expand Down
17 changes: 4 additions & 13 deletions src/main/java/mods/railcraft/world/module/BlastFurnaceModule.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mods.railcraft.world.module;

import java.util.function.IntSupplier;
import org.jetbrains.annotations.NotNull;
import mods.railcraft.api.container.manipulator.ContainerManipulator;
import mods.railcraft.util.container.ContainerMapper;
Expand All @@ -12,8 +11,8 @@
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
Expand All @@ -27,7 +26,7 @@ public class BlastFurnaceModule extends CookingModule<BlastFurnaceRecipe, BlastF
private static final int FUEL_PER_TICK = 5;
private final ContainerMapper fuelContainer, outputContainer, slagContainer;

private LazyOptional<IItemHandler> itemHandler;
private final LazyOptional<IItemHandler> itemHandler;

/**
* The number of ticks that the furnace will keep burning
Expand Down Expand Up @@ -126,16 +125,8 @@ public boolean needsFuel() {
return this.getItem(SLOT_FUEL).getCount() < 8;
}

public int getItemBurnTime(ItemStack itemStack) {
return getVanillaBurnTimeOr(itemStack,
() -> itemStack.getBurnTime(RailcraftRecipeTypes.BLASTING.get()));
}

private static int getVanillaBurnTimeOr(ItemStack itemStack, IntSupplier defaultTime) {
if (itemStack.is(Items.CHARCOAL)) {
return 1600;
}
return defaultTime.getAsInt();
private int getItemBurnTime(ItemStack itemStack) {
return ForgeHooks.getBurnTime(itemStack, null);
}

private void loadFuel() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/mods/railcraft/world/module/CokeOvenModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class CokeOvenModule extends CookingModule<CokeOvenRecipe, CokeOvenBlockE
private FluidTools.ProcessState processState = FluidTools.ProcessState.RESET;
private final ContainerMapper fluidContainer;

private LazyOptional<IItemHandler> itemHandler;
private LazyOptional<IFluidHandler> fluidHandler;
private final LazyOptional<IItemHandler> itemHandler;
private final LazyOptional<IFluidHandler> fluidHandler;

public CokeOvenModule(CokeOvenBlockEntity provider) {
super(provider, 5, SLOT_INPUT);
Expand Down Expand Up @@ -132,8 +132,8 @@ public StandardTank getTank() {
public boolean canPlaceItem(int slot, ItemStack itemStack) {
return switch (slot) {
case SLOT_INPUT -> this.getRecipeFor(itemStack).isPresent();
case SLOT_LIQUID_INPUT -> FluidItemHelper.isRoomInContainer(itemStack,
RailcraftFluids.CREOSOTE.get());
case SLOT_LIQUID_INPUT ->
FluidItemHelper.isRoomInContainer(itemStack, RailcraftFluids.CREOSOTE.get());
case SLOT_OUTPUT, SLOT_LIQUID_PROCESSING, SLOT_LIQUID_OUTPUT -> true;
default -> false;
} && super.canPlaceItem(slot, itemStack);
Expand Down

0 comments on commit 8bb4a4f

Please sign in to comment.