made the blast furnace booster only work on ores

This commit is contained in:
Ellpeck 2020-05-02 02:24:16 +02:00
parent 68bf15b791
commit 0175c836e2

View file

@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tileentity.BlastFurnaceTileEntity; import net.minecraft.tileentity.BlastFurnaceTileEntity;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -16,6 +17,7 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.List;
public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity { public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITickableTileEntity {
@ -35,6 +37,8 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
IRecipe<?> recipe = this.world.getRecipeManager().getRecipe(TileEntityFurnaceHeater.getRecipeType(tile), tile, this.world).orElse(null); IRecipe<?> recipe = this.world.getRecipeManager().getRecipe(TileEntityFurnaceHeater.getRecipeType(tile), tile, this.world).orElse(null);
if (recipe == null) if (recipe == null)
return; return;
if (!this.isApplicable(recipe.getIngredients()))
return;
IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile); IIntArray data = TileEntityFurnaceHeater.getFurnaceData(tile);
int doneDiff = data.get(3) - data.get(2); int doneDiff = data.get(3) - data.get(2);
@ -65,6 +69,16 @@ public class TileEntityBlastFurnaceBooster extends TileEntityImpl implements ITi
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1));
} }
private boolean isApplicable(List<Ingredient> ingredients) {
for (Ingredient ing : ingredients) {
for (ItemStack stack : ing.getMatchingStacks()) {
if (stack.getItem().getTags().stream().anyMatch(t -> t.getPath().startsWith("ores/")))
return true;
}
}
return false;
}
@Override @Override
public IItemHandlerModifiable getItemHandler(Direction facing) { public IItemHandlerModifiable getItemHandler(Direction facing) {
TileEntity below = this.world.getTileEntity(this.pos.down()); TileEntity below = this.world.getTileEntity(this.pos.down());