Skip to content

Instantly share code, notes, and snippets.

@Toma400
Last active February 10, 2022 21:44
Show Gist options
  • Save Toma400/e55fd2db810e380cc584f6eb16d9323f to your computer and use it in GitHub Desktop.
Save Toma400/e55fd2db810e380cc584f6eb16d9323f to your computer and use it in GitHub Desktop.
Useful simplification of fuel code
package toma400.cobr.core;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeType;
import javax.annotation.Nullable;
public class CobrFuels extends Item {
public CobrFuels(Properties pProperties) {
super(pProperties);
}
@Override
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
int FuelTime;
//condition below checks for specific item and gives it fuel time, so you can basically add as many item checkers as possible, making this class the only one needed for any fuel
if (itemStack.getItem() == CobrItems.DUNE_COAL.get()) {
FuelTime = 2000;
}
if (itemStack.getItem() == CobrBlocks.DUNE_COAL_BLOCK.get().asItem()) { //this is for block item, just remember it needs to be assigned to this class (CobrFuels in this case); I made easier workaround here, so you don't need to include blocks in CobrFuels: https://gist.github.com/Toma400/8f9336027caec6b2fd46b7b7b3032617
FuelTime = 18000;
}
else {
FuelTime = 0;
}
return FuelTime;
}
}
@Toma400
Copy link
Author

Toma400 commented Feb 10, 2022

Created as simplified version of Kaupenjoe's tutorial .class file in his tutorial. I simplified it that it now needs only one file for any fuel in the mod, so you don't need to make separate files for each item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment