|
| 1 | +package com.mmodding.mmodding_lib.library.blocks; |
| 2 | + |
| 3 | +import net.minecraft.block.WallTorchBlock; |
| 4 | +import net.minecraft.item.BlockItem; |
| 5 | +import net.minecraft.item.Item; |
| 6 | +import net.minecraft.item.ItemGroup; |
| 7 | +import net.minecraft.particle.ParticleEffect; |
| 8 | +import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; |
| 9 | + |
| 10 | +import java.util.concurrent.atomic.AtomicBoolean; |
| 11 | + |
| 12 | +public class CustomWallTorchBlock extends WallTorchBlock implements BlockRegistrable, BlockWithItem { |
| 13 | + |
| 14 | + private final AtomicBoolean registered = new AtomicBoolean(false); |
| 15 | + |
| 16 | + private BlockItem item = null; |
| 17 | + |
| 18 | + public CustomWallTorchBlock(Settings settings, ParticleEffect particle) { |
| 19 | + this(settings, particle, false); |
| 20 | + } |
| 21 | + |
| 22 | + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem) { |
| 23 | + this(settings, particle, hasItem, (ItemGroup) null); |
| 24 | + } |
| 25 | + |
| 26 | + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem, ItemGroup itemGroup) { |
| 27 | + this(settings, particle, hasItem, itemGroup != null ? new QuiltItemSettings().group(itemGroup) : new QuiltItemSettings()); |
| 28 | + } |
| 29 | + |
| 30 | + public CustomWallTorchBlock(Settings settings, ParticleEffect particle, boolean hasItem, Item.Settings itemSettings) { |
| 31 | + super(settings, particle); |
| 32 | + if (hasItem) this.item = new BlockItem(this, itemSettings); |
| 33 | + } |
| 34 | + |
| 35 | + @Override |
| 36 | + public BlockItem getItem() { |
| 37 | + return this.item; |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public boolean isNotRegistered() { |
| 42 | + return !this.registered.get(); |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public void setRegistered() { |
| 47 | + this.registered.set(true); |
| 48 | + } |
| 49 | +} |
0 commit comments