Sign and Chest patterns
This commit is contained in:
parent
d99f8225a8
commit
6c74d8c364
28 changed files with 120 additions and 70 deletions
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -9,15 +10,21 @@ import net.minecraft.block.ChestBlock;
|
|||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContext;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.BlockView;
|
||||
import ru.betterend.interfaces.Patterned;
|
||||
import ru.betterend.registry.BlockEntityRegistry;
|
||||
|
||||
public class BlockChest extends ChestBlock
|
||||
{
|
||||
public class BlockChest extends ChestBlock implements Patterned {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public BlockChest(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).nonOpaque(), () -> {
|
||||
return BlockEntityRegistry.CHEST;
|
||||
});
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,4 +40,26 @@ public class BlockChest extends ChestBlock
|
|||
drop.add(new ItemStack(this.asItem()));
|
||||
return drop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatesPattern(Reader data) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||
return Patterned.createJson(data, parentId, blockId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPattern(String path) {
|
||||
Identifier blockId = Registry.BLOCK.getId(this);
|
||||
Identifier parentId = Registry.BLOCK.getId(parent);
|
||||
if (path.contains("item")) {
|
||||
return Patterned.createJson(Patterned.CHEST_ITEM_MODEL, blockId.getPath());
|
||||
}
|
||||
return Patterned.createJson(Patterned.EMPTY_MODEL, parentId.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.BLOCK_STATES_PATTERN;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue