Fence pattern
This commit is contained in:
parent
fe8070f0d4
commit
1dc48360dc
9 changed files with 103 additions and 218 deletions
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,14 +10,44 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
|
||||
public class BlockFence extends FenceBlock {
|
||||
public class BlockFence extends FenceBlock implements Patterned {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public BlockFence(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).nonOpaque());
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
|
||||
return Collections.singletonList(new ItemStack(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data, String block) {
|
||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||
return Patterned.createJson(data, parentId, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String block) {
|
||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||
if (block.contains("item")) {
|
||||
return Patterned.createJson(Patterned.FENCE_ITEM_MODEL, parentId, block);
|
||||
}
|
||||
if (block.contains("side")) {
|
||||
return Patterned.createJson(Patterned.FENCE_SIDE_MODEL, parentId, block);
|
||||
}
|
||||
return Patterned.createJson(Patterned.FENCE_POST_MODEL, parentId, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.FENCE_STATES_PATTERN;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue