From d5a671ca200dec8e75ba27254f5e8f4e8d714693 Mon Sep 17 00:00:00 2001
From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com>
Date: Sun, 30 Jun 2024 13:22:39 -0700
Subject: [PATCH] Wooden crucibles/barrels are now furnace fuels
---
.../exdeorum/item/WoodenBlockItem.java | 37 +++++++++++++++++++
.../exdeorum/material/AbstractMaterial.java | 5 +++
.../exdeorum/material/BarrelMaterial.java | 12 ++++++
.../exdeorum/material/MaterialRegistry.java | 3 +-
.../material/WaterCrucibleMaterial.java | 8 ++++
5 files changed, 64 insertions(+), 1 deletion(-)
create mode 100644 src/main/java/thedarkcolour/exdeorum/item/WoodenBlockItem.java
diff --git a/src/main/java/thedarkcolour/exdeorum/item/WoodenBlockItem.java b/src/main/java/thedarkcolour/exdeorum/item/WoodenBlockItem.java
new file mode 100644
index 00000000..cad50d67
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/item/WoodenBlockItem.java
@@ -0,0 +1,37 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.item;
+
+import net.minecraft.world.item.BlockItem;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.crafting.RecipeType;
+import net.minecraft.world.level.block.Block;
+import org.jetbrains.annotations.Nullable;
+
+// BlockItem except it is furnace fuel
+public class WoodenBlockItem extends BlockItem {
+ public WoodenBlockItem(Block block, Properties properties) {
+ super(block, properties);
+ }
+
+ @Override
+ public int getBurnTime(ItemStack itemStack, @Nullable RecipeType> recipeType) {
+ return 300;
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java
index 7a7c708c..69e3c1e2 100644
--- a/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java
+++ b/src/main/java/thedarkcolour/exdeorum/material/AbstractMaterial.java
@@ -25,6 +25,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.registries.RegistryObject;
+import thedarkcolour.exdeorum.registry.EItems;
public abstract class AbstractMaterial implements ItemLike {
// The sound this block makes (a string corresponding to a field in SoundType or a JSON object with the five sound events used to create a sound type)
@@ -51,6 +52,10 @@ public abstract class AbstractMaterial implements ItemLike {
protected abstract Block createBlock();
+ protected BlockItem createBlockItem(Block block) {
+ return new BlockItem(block, EItems.props());
+ }
+
protected BlockBehaviour.Properties props() {
var properties = BlockBehaviour.Properties.of().strength(this.strength).sound(this.soundType);
if (this.needsCorrectTool) properties.requiresCorrectToolForDrops();
diff --git a/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java
index 2df47081..9aec109b 100644
--- a/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java
+++ b/src/main/java/thedarkcolour/exdeorum/material/BarrelMaterial.java
@@ -18,10 +18,13 @@
package thedarkcolour.exdeorum.material;
+import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.exdeorum.block.BarrelBlock;
+import thedarkcolour.exdeorum.item.WoodenBlockItem;
+import thedarkcolour.exdeorum.registry.EItems;
import java.util.HashSet;
import java.util.Set;
@@ -48,6 +51,15 @@ public class BarrelMaterial extends AbstractMaterial {
return new BarrelBlock(props);
}
+ @Override
+ protected BlockItem createBlockItem(Block block) {
+ if (!this.fireproof) {
+ return new WoodenBlockItem(block, EItems.props());
+ } else {
+ return super.createBlockItem(block);
+ }
+ }
+
@Nullable
public static BarrelMaterial readFromJson(MaterialParser parser) {
SoundType soundType = parser.getSoundType();
diff --git a/src/main/java/thedarkcolour/exdeorum/material/MaterialRegistry.java b/src/main/java/thedarkcolour/exdeorum/material/MaterialRegistry.java
index 89af4dbd..49cefcca 100644
--- a/src/main/java/thedarkcolour/exdeorum/material/MaterialRegistry.java
+++ b/src/main/java/thedarkcolour/exdeorum/material/MaterialRegistry.java
@@ -22,6 +22,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
@@ -98,7 +99,7 @@ public class MaterialRegistry implements Iterable
}
material.block = EBlocks.BLOCKS.register(id, material::createBlock);
- material.item = EItems.registerItemBlock(material.block);
+ material.item = EItems.ITEMS.register(id, () -> material.createBlockItem(material.block.get()));
this.values.add(material);
}
diff --git a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java
index 83549030..0f79a87c 100644
--- a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java
+++ b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java
@@ -18,9 +18,12 @@
package thedarkcolour.exdeorum.material;
+import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import thedarkcolour.exdeorum.block.WaterCrucibleBlock;
+import thedarkcolour.exdeorum.item.WoodenBlockItem;
+import thedarkcolour.exdeorum.registry.EItems;
public class WaterCrucibleMaterial extends AbstractCrucibleMaterial {
protected WaterCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId, boolean transparent) {
@@ -31,4 +34,9 @@ public class WaterCrucibleMaterial extends AbstractCrucibleMaterial {
protected Block createBlock() {
return new WaterCrucibleBlock(props().noOcclusion());
}
+
+ @Override
+ protected BlockItem createBlockItem(Block block) {
+ return new WoodenBlockItem(block, EItems.props());
+ }
}