From 06c06d340c2e1b2d8f38c619f6d2f332eebfec70 Mon Sep 17 00:00:00 2001 From: FirstMegaGame4 <84094287+FirstMegaGame4@users.noreply.github.com> Date: Sat, 8 Feb 2025 12:22:25 +0100 Subject: [PATCH] Add CustomWallTorchBlock --- .../library/blocks/CustomWallTorchBlock.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/main/java/com/mmodding/mmodding_lib/library/blocks/CustomWallTorchBlock.java diff --git a/src/main/java/com/mmodding/mmodding_lib/library/blocks/CustomWallTorchBlock.java b/src/main/java/com/mmodding/mmodding_lib/library/blocks/CustomWallTorchBlock.java new file mode 100644 index 0000000..630d2fa --- /dev/null +++ b/src/main/java/com/mmodding/mmodding_lib/library/blocks/CustomWallTorchBlock.java @@ -0,0 +1,49 @@ +package com.mmodding.mmodding_lib.library.blocks; + +import net.minecraft.block.WallTorchBlock; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.particle.ParticleEffect; +import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; + +import java.util.concurrent.atomic.AtomicBoolean; + +public class CustomWallTorchBlock extends WallTorchBlock implements BlockRegistrable, BlockWithItem { + + private final AtomicBoolean registered = new AtomicBoolean(false); + + private BlockItem item = null; + + public CustomWallTorchBlock(Settings settings, ParticleEffect particle) { + this(settings, particle, false); + } + + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem) { + this(settings, particle, hasItem, (ItemGroup) null); + } + + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem, ItemGroup itemGroup) { + this(settings, particle, hasItem, itemGroup != null ? new QuiltItemSettings().group(itemGroup) : new QuiltItemSettings()); + } + + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem, Item.Settings itemSettings) { + super(settings, particle); + if (hasItem) this.item = new BlockItem(this, itemSettings); + } + + @Override + public BlockItem getItem() { + return this.item; + } + + @Override + public boolean isNotRegistered() { + return !this.registered.get(); + } + + @Override + public void setRegistered() { + this.registered.set(true); + } +}