Fence Gate pattern
This commit is contained in:
parent
1dc48360dc
commit
7d0363483c
7 changed files with 146 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,15 +10,48 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.FenceGateBlock;
|
||||
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 BlockGate extends FenceGateBlock
|
||||
{
|
||||
public class BlockGate extends FenceGateBlock implements Patterned {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public BlockGate(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("wall")) {
|
||||
if (block.contains("open")) {
|
||||
return Patterned.createJson(Patterned.GATE_MODEL_WALL_OPEN, parentId, block);
|
||||
} else {
|
||||
return Patterned.createJson(Patterned.GATE_MODEL_WALL_CLOSED, parentId, block);
|
||||
}
|
||||
}
|
||||
if (block.contains("open")) {
|
||||
return Patterned.createJson(Patterned.GATE_MODEL_OPEN, parentId, block);
|
||||
}
|
||||
return Patterned.createJson(Patterned.GATE_MODEL_CLOSED, parentId, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier statePatternId() {
|
||||
return Patterned.GATE_STATES_PATTERN;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue