-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1af7c8d
commit 636133f
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/com/mmodding/mmodding_lib/library/blocks/CustomChainBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.mmodding.mmodding_lib.library.blocks; | ||
|
||
import net.minecraft.block.ChainBlock; | ||
import net.minecraft.item.BlockItem; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemGroup; | ||
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class CustomChainBlock extends ChainBlock implements BlockRegistrable, BlockWithItem { | ||
|
||
private final AtomicBoolean registered = new AtomicBoolean(false); | ||
|
||
private BlockItem item = null; | ||
|
||
public CustomChainBlock(Settings settings) { | ||
this(settings, false); | ||
} | ||
|
||
public CustomChainBlock(Settings settings, boolean hasItem) { | ||
this(settings, hasItem, (ItemGroup) null); | ||
} | ||
|
||
public CustomChainBlock(Settings settings, boolean hasItem, ItemGroup itemGroup) { | ||
this(settings, hasItem, itemGroup != null ? new QuiltItemSettings().group(itemGroup) : new QuiltItemSettings()); | ||
} | ||
|
||
public CustomChainBlock(Settings settings, boolean hasItem, Item.Settings itemSettings) { | ||
super(settings); | ||
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); | ||
} | ||
} |