This commit is contained in:
Frank 2022-07-27 00:04:12 +02:00
parent abf24a41da
commit 12abe35dcf
3 changed files with 24 additions and 5 deletions

View file

@ -10,6 +10,7 @@ import org.betterx.bclib.client.render.BCLRenderLayer;
import org.betterx.bclib.client.render.BaseChestBlockEntityRenderer;
import org.betterx.bclib.client.render.BaseSignBlockEntityRenderer;
import org.betterx.bclib.config.Configs;
import org.betterx.bclib.interfaces.Fuel;
import org.betterx.bclib.interfaces.PostInitable;
import org.betterx.bclib.interfaces.RenderLayerProvider;
import org.betterx.bclib.interfaces.TagProvider;
@ -28,6 +29,7 @@ import net.minecraft.world.level.block.Block;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import com.google.common.collect.Lists;
@ -148,5 +150,9 @@ public class PostInitAPI {
blockTags.clear();
itemTags.clear();
}
if (block instanceof Fuel fl) {
FuelRegistry.INSTANCE.add(block, fl.getFuelTime());
}
}
}

View file

@ -0,0 +1,5 @@
package org.betterx.bclib.interfaces;
public interface Fuel {
int getFuelTime();
}

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.registry;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.blocks.BaseLeavesBlock;
import org.betterx.bclib.blocks.BaseOreBlock;
import org.betterx.bclib.blocks.FeatureSaplingBlock;
@ -29,18 +30,25 @@ public class BlockRegistry extends BaseRegistry<Block> {
@Override
public Block register(ResourceLocation id, Block block) {
System.out.println("Register Block " + id + ", " + Item.BY_BLOCK.containsKey(block));
if (!config.getBooleanRoot(id.getNamespace(), true)) {
BCLib.LOGGER.warning("Block " + id + " disabled");
return block;
}
System.out.println(" has " + id + ", " + Item.BY_BLOCK.containsKey(block));
BlockItem item = null;
if (block instanceof CustomItemProvider) {
System.out.println("Get Item for " + id + ": CustomItemProvider");
item = ((CustomItemProvider) block).getCustomItem(id, makeItemSettings());
} else {
System.out.println("Get Item for " + id + ": BlockItem");
item = new BlockItem(block, makeItemSettings());
}
System.out.println(" has " + id + ", " + Item.BY_BLOCK.containsKey(block));
registerBlockItem(id, item);
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance()
if (block.defaultBlockState().getMaterial().isFlammable()
&& FlammableBlockRegistry.getDefaultInstance()
.get(block)
.getBurnChance() == 0) {
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
@ -80,7 +88,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
return Registry.register(Registry.BLOCK, id, block);
}
private Item registerBlockItem(ResourceLocation id, Item item) {
private Item registerBlockItem(ResourceLocation id, BlockItem item) {
registerItem(id, item);
return item;
}