[Feature] Fuel API (quiqueck/BetterEnd#41)
This commit is contained in:
parent
abf24a41da
commit
12abe35dcf
3 changed files with 24 additions and 5 deletions
|
@ -10,6 +10,7 @@ import org.betterx.bclib.client.render.BCLRenderLayer;
|
||||||
import org.betterx.bclib.client.render.BaseChestBlockEntityRenderer;
|
import org.betterx.bclib.client.render.BaseChestBlockEntityRenderer;
|
||||||
import org.betterx.bclib.client.render.BaseSignBlockEntityRenderer;
|
import org.betterx.bclib.client.render.BaseSignBlockEntityRenderer;
|
||||||
import org.betterx.bclib.config.Configs;
|
import org.betterx.bclib.config.Configs;
|
||||||
|
import org.betterx.bclib.interfaces.Fuel;
|
||||||
import org.betterx.bclib.interfaces.PostInitable;
|
import org.betterx.bclib.interfaces.PostInitable;
|
||||||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||||
import org.betterx.bclib.interfaces.TagProvider;
|
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.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||||
|
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
@ -148,5 +150,9 @@ public class PostInitAPI {
|
||||||
blockTags.clear();
|
blockTags.clear();
|
||||||
itemTags.clear();
|
itemTags.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (block instanceof Fuel fl) {
|
||||||
|
FuelRegistry.INSTANCE.add(block, fl.getFuelTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
src/main/java/org/betterx/bclib/interfaces/Fuel.java
Normal file
5
src/main/java/org/betterx/bclib/interfaces/Fuel.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package org.betterx.bclib.interfaces;
|
||||||
|
|
||||||
|
public interface Fuel {
|
||||||
|
int getFuelTime();
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package org.betterx.bclib.registry;
|
package org.betterx.bclib.registry;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
import org.betterx.bclib.blocks.BaseLeavesBlock;
|
import org.betterx.bclib.blocks.BaseLeavesBlock;
|
||||||
import org.betterx.bclib.blocks.BaseOreBlock;
|
import org.betterx.bclib.blocks.BaseOreBlock;
|
||||||
import org.betterx.bclib.blocks.FeatureSaplingBlock;
|
import org.betterx.bclib.blocks.FeatureSaplingBlock;
|
||||||
|
@ -29,20 +30,27 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block register(ResourceLocation id, Block block) {
|
public Block register(ResourceLocation id, Block block) {
|
||||||
|
System.out.println("Register Block " + id + ", " + Item.BY_BLOCK.containsKey(block));
|
||||||
if (!config.getBooleanRoot(id.getNamespace(), true)) {
|
if (!config.getBooleanRoot(id.getNamespace(), true)) {
|
||||||
|
BCLib.LOGGER.warning("Block " + id + " disabled");
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
System.out.println(" has " + id + ", " + Item.BY_BLOCK.containsKey(block));
|
||||||
BlockItem item = null;
|
BlockItem item = null;
|
||||||
if (block instanceof CustomItemProvider) {
|
if (block instanceof CustomItemProvider) {
|
||||||
|
System.out.println("Get Item for " + id + ": CustomItemProvider");
|
||||||
item = ((CustomItemProvider) block).getCustomItem(id, makeItemSettings());
|
item = ((CustomItemProvider) block).getCustomItem(id, makeItemSettings());
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("Get Item for " + id + ": BlockItem");
|
||||||
item = new BlockItem(block, makeItemSettings());
|
item = new BlockItem(block, makeItemSettings());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
System.out.println(" has " + id + ", " + Item.BY_BLOCK.containsKey(block));
|
||||||
registerBlockItem(id, item);
|
registerBlockItem(id, item);
|
||||||
if (block.defaultBlockState().getMaterial().isFlammable() && FlammableBlockRegistry.getDefaultInstance()
|
if (block.defaultBlockState().getMaterial().isFlammable()
|
||||||
.get(block)
|
&& FlammableBlockRegistry.getDefaultInstance()
|
||||||
.getBurnChance() == 0) {
|
.get(block)
|
||||||
|
.getBurnChance() == 0) {
|
||||||
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
|
FlammableBlockRegistry.getDefaultInstance().add(block, 5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +88,7 @@ public class BlockRegistry extends BaseRegistry<Block> {
|
||||||
return Registry.register(Registry.BLOCK, id, 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);
|
registerItem(id, item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue