Patterns refactor

This commit is contained in:
Aleksey 2020-11-17 22:04:42 +03:00
parent ce8ae2e7fe
commit 14434e4028
33 changed files with 397 additions and 356 deletions

View file

@ -8,7 +8,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.BlockPedestal; import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
public class EndPedestal extends BlockPedestal { public class EndPedestal extends BlockPedestal {
@ -31,16 +31,16 @@ public class EndPedestal extends BlockPedestal {
} }
}; };
if (block.contains("column_top")) { if (block.contains("column_top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_COLUMN_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
} else if (block.contains("column")) { } else if (block.contains("column")) {
return Patterned.createJson(Patterned.BLOKC_PEDESTAL_COLUMN, textures); return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
} else if (block.contains("top")) { } else if (block.contains("top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
} else if (block.contains("bottom")) { } else if (block.contains("bottom")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_BOTTOM, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
} else if (block.contains("pillar")) { } else if (block.contains("pillar")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_PILLAR, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
} }
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_DEFAULT, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
} }
} }

View file

@ -7,7 +7,7 @@ import net.minecraft.block.Block;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.blocks.basis.BlockPedestal; import ru.betterend.blocks.basis.BlockPedestal;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
public class PedestalVanilla extends BlockPedestal { public class PedestalVanilla extends BlockPedestal {
@ -30,16 +30,16 @@ public class PedestalVanilla extends BlockPedestal {
} }
}; };
if (block.contains("column_top")) { if (block.contains("column_top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_COLUMN_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
} else if (block.contains("column")) { } else if (block.contains("column")) {
return Patterned.createJson(Patterned.BLOKC_PEDESTAL_COLUMN, textures); return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
} else if (block.contains("top")) { } else if (block.contains("top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
} else if (block.contains("bottom")) { } else if (block.contains("bottom")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_BOTTOM, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
} else if (block.contains("pillar")) { } else if (block.contains("pillar")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_PILLAR, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
} }
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_DEFAULT, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
} }
} }

View file

@ -4,8 +4,8 @@ import java.io.Reader;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
public class BlockBark extends BlockPillar { public class BlockBark extends BlockPillar {
public BlockBark(Settings settings) { public BlockBark(Settings settings) {
@ -15,15 +15,13 @@ public class BlockBark extends BlockPillar {
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId); return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
return Patterned.createJson(Patterned.BLOCK_BASE, BetterEnd.makeID(name), blockId.getPath());
} }
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId); return Patterns.createJson(data, getName(blockId), blockId.getPath());
return Patterned.createJson(data, BetterEnd.makeID(name), blockId.getPath());
} }
private String getName(Identifier blockId) { private String getName(Identifier blockId) {

View file

@ -26,10 +26,11 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import ru.betterend.blocks.entities.EBarrelBlockEntity; import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlockEntities; import ru.betterend.registry.EndBlockEntities;
public class BlockBarrel extends BarrelBlock implements Patterned { public class BlockBarrel extends BarrelBlock implements BlockPatterned {
public BlockBarrel(Block source) { public BlockBarrel(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque()); super(FabricBlockSettings.copyOf(source).nonOpaque());
} }
@ -89,21 +90,21 @@ public class BlockBarrel extends BarrelBlock implements Patterned {
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String block = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, block, block);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
if (block.contains("open")) { if (block.contains("open")) {
return Patterned.createJson(Patterned.BLOCK_BARREL_OPEN, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
} }
return Patterned.createJson(Patterned.BLOCK_BOTTOM_TOP, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_BARREL; return Patterns.STATE_BARREL;
} }
} }

View file

@ -10,9 +10,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockBase extends Block implements Patterned { public class BlockBase extends Block implements BlockPatterned {
public BlockBase(Settings settings) { public BlockBase(Settings settings) {
super(settings); super(settings);
} }
@ -24,18 +25,18 @@ public class BlockBase extends Block implements Patterned {
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String block = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, block, block);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(Patterned.BLOCK_BASE, blockId, block); return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
} }

View file

@ -15,8 +15,8 @@ import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters; import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
public class BlockBookshelf extends BlockBase { public class BlockBookshelf extends BlockBase {
public BlockBookshelf(Block source) { public BlockBookshelf(Block source) {
@ -37,21 +37,19 @@ public class BlockBookshelf extends BlockBase {
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId); return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
return Patterned.createJson(Patterned.BLOCK_BOOKSHELF, BetterEnd.makeID(name), blockId.getPath());
} }
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String name = getName(blockId); return Patterns.createJson(data, getName(blockId), blockId.getPath());
return Patterned.createJson(data, BetterEnd.makeID(name), blockId.getPath());
} }
private String getName(Identifier blockId) { private String getName(Identifier blockId) {

View file

@ -13,10 +13,11 @@ import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlockEntities; import ru.betterend.registry.EndBlockEntities;
public class BlockChest extends ChestBlock implements Patterned { public class BlockChest extends ChestBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -45,7 +46,7 @@ public class BlockChest extends ChestBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -53,13 +54,13 @@ public class BlockChest extends ChestBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (path.contains("item")) { if (path.contains("item")) {
return Patterned.createJson(Patterned.ITEM_CHEST, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_EMPTY, parentId.getPath()); return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
} }

View file

@ -13,9 +13,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockCraftingTable extends CraftingTableBlock implements Patterned { public class BlockCraftingTable extends CraftingTableBlock implements BlockPatterned {
public BlockCraftingTable(Block source) { public BlockCraftingTable(Block source) {
super(FabricBlockSettings.copyOf(source)); super(FabricBlockSettings.copyOf(source));
} }
@ -27,15 +28,15 @@ public class BlockCraftingTable extends CraftingTableBlock implements Patterned
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, blockId, blockId);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String blockName = blockId.getPath(); String blockName = blockId.getPath();
return Patterned.createJson(Patterned.BLOCK_SIDED, new HashMap<String, String>() { return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("%particle%", blockName + "_front"); put("%particle%", blockName + "_front");
@ -51,6 +52,6 @@ public class BlockCraftingTable extends CraftingTableBlock implements Patterned
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
} }

View file

@ -15,9 +15,10 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockDoor extends DoorBlock implements IRenderTypeable, Patterned { public class BlockDoor extends DoorBlock implements IRenderTypeable, BlockPatterned {
public BlockDoor(Block block) { public BlockDoor(Block block) {
super(FabricBlockSettings.copy(block).nonOpaque()); super(FabricBlockSettings.copy(block).nonOpaque());
} }
@ -37,30 +38,30 @@ public class BlockDoor extends DoorBlock implements IRenderTypeable, Patterned {
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, blockId, blockId);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_MODEL, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_MODEL, blockId);
} }
if (block.contains("top_hinge")) { if (block.contains("top_hinge")) {
return Patterned.createJson(Patterned.BLOCK_DOOR_TOP_HINGE, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_DOOR_TOP_HINGE, blockId, blockId);
} }
if (block.contains("bottom_hinge")) { if (block.contains("bottom_hinge")) {
return Patterned.createJson(Patterned.BLOCK_DOOR_BOTTOM_HINGE, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM_HINGE, blockId, blockId);
} }
if (block.contains("top")) { if (block.contains("top")) {
return Patterned.createJson(Patterned.BLOCK_DOOR_TOP, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_DOOR_TOP, blockId, blockId);
} }
return Patterned.createJson(Patterned.BLOCK_DOOR_BOTTOM, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_DOOR; return Patterns.STATE_DOOR;
} }
} }

View file

@ -24,7 +24,7 @@ import net.minecraft.world.WorldView;
import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.Feature;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndTags; import ru.betterend.registry.EndTags;
public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable { public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
@ -100,20 +100,20 @@ public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fe
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, blockId.getPath(), blockId.getPath());
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
if (block.contains("item")) { if (block.contains("item")) {
block = block.split("/")[1]; block = block.split("/")[1];
return Patterned.createJson(Patterned.ITEM_BLOCK, block); return Patterns.createJson(Patterns.ITEM_BLOCK, block);
} }
return Patterned.createJson(Patterned.BLOCK_SAPLING, block); return Patterns.createJson(Patterns.BLOCK_SAPLING, block);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SAPLING; return Patterns.STATE_SAPLING;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockFence extends FenceBlock implements Patterned { public class BlockFence extends FenceBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockFence extends FenceBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,16 +41,16 @@ public class BlockFence extends FenceBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_FENCE, parentId, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath());
} }
if (block.contains("side")) { if (block.contains("side")) {
return Patterned.createJson(Patterned.BLOCK_FENCE_SIDE, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_FENCE_SIDE, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_FENCE_POST, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_FENCE; return Patterns.STATE_FENCE;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockGate extends FenceGateBlock implements Patterned { public class BlockGate extends FenceGateBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockGate extends FenceGateBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -41,19 +42,19 @@ public class BlockGate extends FenceGateBlock implements Patterned {
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("wall")) { if (block.contains("wall")) {
if (block.contains("open")) { if (block.contains("open")) {
return Patterned.createJson(Patterned.BLOCK_GATE_OPEN_WALL, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_GATE_OPEN_WALL, parentId.getPath(), blockId.getPath());
} else { } else {
return Patterned.createJson(Patterned.BLOCK_GATE_CLOSED_WALL, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED_WALL, parentId.getPath(), blockId.getPath());
} }
} }
if (block.contains("open")) { if (block.contains("open")) {
return Patterned.createJson(Patterned.BLOCK_GATE_OPEN, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_GATE_OPEN, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_GATE_CLOSED, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_GATE_CLOSED, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_GATE; return Patterns.STATE_GATE;
} }
} }

View file

@ -27,10 +27,11 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable, Patterned { public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable, BlockPatterned {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING; public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED;
protected static final VoxelShape EAST_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D); protected static final VoxelShape EAST_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 16.0D);
@ -138,21 +139,21 @@ public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable, Pa
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, blockId, blockId);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_BLOCK, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_LADDER, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_LADDER, blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_LADDER; return Patterns.STATE_LADDER;
} }
} }

View file

@ -10,9 +10,10 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockLeaves extends LeavesBlock implements Patterned, IRenderTypeable { public class BlockLeaves extends LeavesBlock implements BlockPatterned, IRenderTypeable {
public BlockLeaves(MaterialColor color) { public BlockLeaves(MaterialColor color) {
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES) super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
.allowsSpawning((state, world, pos, type) -> { return false; }) .allowsSpawning((state, world, pos, type) -> { return false; })
@ -32,19 +33,19 @@ public class BlockLeaves extends LeavesBlock implements Patterned, IRenderTypeab
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, blockId, blockId);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String blockId = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(Patterned.BLOCK_BASE, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
@Override @Override

View file

@ -39,7 +39,7 @@ import net.minecraft.world.WorldAccess;
import ru.betterend.blocks.BlockProperties; import ru.betterend.blocks.BlockProperties;
import ru.betterend.blocks.BlockProperties.PedestalState; import ru.betterend.blocks.BlockProperties.PedestalState;
import ru.betterend.blocks.entities.PedestalBlockEntity; import ru.betterend.blocks.entities.PedestalBlockEntity;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
@ -304,8 +304,8 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, texture, texture);
} }
@Override @Override
@ -323,22 +323,22 @@ public class BlockPedestal extends BlockBaseNotFull implements BlockEntityProvid
} }
}; };
if (block.contains("column_top")) { if (block.contains("column_top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_COLUMN_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
} else if (block.contains("column")) { } else if (block.contains("column")) {
return Patterned.createJson(Patterned.BLOKC_PEDESTAL_COLUMN, textures); return Patterns.createJson(Patterns.BLOKC_PEDESTAL_COLUMN, textures);
} else if (block.contains("top")) { } else if (block.contains("top")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_TOP, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_TOP, textures);
} else if (block.contains("bottom")) { } else if (block.contains("bottom")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_BOTTOM, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_BOTTOM, textures);
} else if (block.contains("pillar")) { } else if (block.contains("pillar")) {
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_PILLAR, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_PILLAR, textures);
} }
return Patterned.createJson(Patterned.BLOCK_PEDESTAL_DEFAULT, textures); return Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_PEDESTAL; return Patterns.STATE_PEDESTAL;
} }
static { static {

View file

@ -10,9 +10,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockPillar extends PillarBlock implements Patterned { public class BlockPillar extends PillarBlock implements BlockPatterned {
public BlockPillar(Settings settings) { public BlockPillar(Settings settings) {
super(settings); super(settings);
} }
@ -24,18 +25,18 @@ public class BlockPillar extends PillarBlock implements Patterned {
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, texture, texture);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(Patterned.BLOCK_PILLAR, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_PILLAR, texture, texture);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_PILLAR; return Patterns.STATE_PILLAR;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockPressurePlate extends PressurePlateBlock implements Patterned { public class BlockPressurePlate extends PressurePlateBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockPressurePlate extends PressurePlateBlock implements Patterned
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,13 +41,13 @@ public class BlockPressurePlate extends PressurePlateBlock implements Patterned
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("down")) { if (block.contains("down")) {
return Patterned.createJson(Patterned.BLOCK_PLATE_DOWN, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_PLATE_UP, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_PLATE; return Patterns.STATE_PLATE;
} }
} }

View file

@ -38,9 +38,10 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldAccess; import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.blocks.entities.ESignBlockEntity; import ru.betterend.blocks.entities.ESignBlockEntity;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockSign extends AbstractSignBlock implements Patterned { public class BlockSign extends AbstractSignBlock implements BlockPatterned {
public static final IntProperty ROTATION = Properties.ROTATION; public static final IntProperty ROTATION = Properties.ROTATION;
public static final BooleanProperty FLOOR = BooleanProperty.of("floor"); public static final BooleanProperty FLOOR = BooleanProperty.of("floor");
private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] { private static final VoxelShape[] WALL_SHAPES = new VoxelShape[] {
@ -154,7 +155,7 @@ public class BlockSign extends AbstractSignBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -162,14 +163,14 @@ public class BlockSign extends AbstractSignBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (path.contains("item")) { if (path.contains("item")) {
return Patterned.createJson(Patterned.ITEM_MODEL, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_MODEL, blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_EMPTY, parentId.getPath()); return Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
@Override @Override

View file

@ -10,7 +10,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
public class BlockSimpleLeaves extends BlockBaseNotFull implements IRenderTypeable { public class BlockSimpleLeaves extends BlockBaseNotFull implements IRenderTypeable {
public BlockSimpleLeaves(MaterialColor color) { public BlockSimpleLeaves(MaterialColor color) {
@ -38,19 +38,19 @@ public class BlockSimpleLeaves extends BlockBaseNotFull implements IRenderTypeab
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, texture, texture);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(Patterned.BLOCK_BASE, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SIMPLE; return Patterns.STATE_SIMPLE;
} }
@Override @Override

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockSlab extends SlabBlock implements Patterned { public class BlockSlab extends SlabBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,18 +33,18 @@ public class BlockSlab extends SlabBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(Patterned.BLOCK_SLAB, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_SLAB; return Patterns.STATE_SLAB;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockStairs extends StairsBlock implements Patterned { public class BlockStairs extends StairsBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockStairs extends StairsBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,16 +41,16 @@ public class BlockStairs extends StairsBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("inner")) { if (block.contains("inner")) {
return Patterned.createJson(Patterned.BLOCK_STAIR_INNER, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
} }
if (block.contains("outer")) { if (block.contains("outer")) {
return Patterned.createJson(Patterned.BLOCK_STAIR_OUTER, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_STAIR, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_STAIRS; return Patterns.STATE_STAIRS;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockStoneButton extends StoneButtonBlock implements Patterned { public class BlockStoneButton extends StoneButtonBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockStoneButton extends StoneButtonBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,16 +41,16 @@ public class BlockStoneButton extends StoneButtonBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_BUTTON, parentId, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
} }
if (block.contains("pressed")) { if (block.contains("pressed")) {
return Patterned.createJson(Patterned.BLOCK_BUTTON_PRESSED, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BUTTON_PRESSED, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_BUTTON, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_BUTTON; return Patterns.STATE_BUTTON;
} }
} }

View file

@ -27,7 +27,7 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView; import net.minecraft.world.WorldView;
import ru.betterend.blocks.AuroraCrystalBlock; import ru.betterend.blocks.AuroraCrystalBlock;
import ru.betterend.interfaces.IColorProvider; import ru.betterend.interfaces.IColorProvider;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterns;
import ru.betterend.util.MHelper; import ru.betterend.util.MHelper;
public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvider, Waterloggable { public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvider, Waterloggable {
@ -126,21 +126,21 @@ public class BlockStoneLantern extends BlockBaseNotFull implements IColorProvide
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_STONE_LANTERN; return Patterns.STATE_STONE_LANTERN;
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); String texture = Registry.BLOCK.getId(this).getPath();
if (block.contains("ceil")) { if (block.contains("ceil")) {
return Patterned.createJson(Patterned.BLOCK_STONE_LANTERN_CEIL, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
} }
return Patterned.createJson(Patterned.BLOCK_STONE_LANTERN_FLOOR, blockId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, texture, texture);
} }
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String block = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, block, block);
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockStonePressurePlate extends PressurePlateBlock implements Patterned { public class BlockStonePressurePlate extends PressurePlateBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockStonePressurePlate extends PressurePlateBlock implements Patte
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,13 +41,13 @@ public class BlockStonePressurePlate extends PressurePlateBlock implements Patte
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("down")) { if (block.contains("down")) {
return Patterned.createJson(Patterned.BLOCK_PLATE_DOWN, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_PLATE_DOWN, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_PLATE_UP, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_PLATE_UP, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_PLATE; return Patterns.STATE_PLATE;
} }
} }

View file

@ -15,9 +15,10 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockTrapdoor extends TrapdoorBlock implements IRenderTypeable, Patterned { public class BlockTrapdoor extends TrapdoorBlock implements IRenderTypeable, BlockPatterned {
public BlockTrapdoor(Block source) { public BlockTrapdoor(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque()); super(FabricBlockSettings.copyOf(source).nonOpaque());
} }
@ -34,15 +35,15 @@ public class BlockTrapdoor extends TrapdoorBlock implements IRenderTypeable, Pat
@Override @Override
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); String block = Registry.BLOCK.getId(this).getPath();
return Patterned.createJson(data, blockId, blockId.getPath()); return Patterns.createJson(data, block, block);
} }
@Override @Override
public String getModelPattern(String block) { public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
String name = blockId.getPath(); String name = blockId.getPath();
return Patterned.createJson(Patterned.BLOCK_TRAPDOOR, new HashMap<String, String>() { return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("%block%", name); put("%block%", name);
@ -53,6 +54,6 @@ public class BlockTrapdoor extends TrapdoorBlock implements IRenderTypeable, Pat
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_TRAPDOOR; return Patterns.STATE_TRAPDOOR;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockWall extends WallBlock implements Patterned { public class BlockWall extends WallBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockWall extends WallBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,19 +41,19 @@ public class BlockWall extends WallBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_WALL, parentId, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_WALL, parentId.getPath(), blockId.getPath());
} }
if (block.contains("side_tall")) { if (block.contains("side_tall")) {
return Patterned.createJson(Patterned.BLOCK_WALL_SIDE_TALL, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_WALL_SIDE_TALL, parentId.getPath(), blockId.getPath());
} }
if (block.contains("side")) { if (block.contains("side")) {
return Patterned.createJson(Patterned.BLOCK_WALL_SIDE, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_WALL_SIDE, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_WALL_POST, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_WALL_POST, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_WALL; return Patterns.STATE_WALL;
} }
} }

View file

@ -12,9 +12,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext; import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns;
public class BlockWoodenButton extends WoodenButtonBlock implements Patterned { public class BlockWoodenButton extends WoodenButtonBlock implements BlockPatterned {
private final Block parent; private final Block parent;
@ -32,7 +33,7 @@ public class BlockWoodenButton extends WoodenButtonBlock implements Patterned {
public String getStatesPattern(Reader data) { public String getStatesPattern(Reader data) {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
return Patterned.createJson(data, parentId, blockId.getPath()); return Patterns.createJson(data, parentId.getPath(), blockId.getPath());
} }
@Override @Override
@ -40,16 +41,16 @@ public class BlockWoodenButton extends WoodenButtonBlock implements Patterned {
Identifier blockId = Registry.BLOCK.getId(this); Identifier blockId = Registry.BLOCK.getId(this);
Identifier parentId = Registry.BLOCK.getId(parent); Identifier parentId = Registry.BLOCK.getId(parent);
if (block.contains("item")) { if (block.contains("item")) {
return Patterned.createJson(Patterned.ITEM_BUTTON, parentId, blockId.getPath()); return Patterns.createJson(Patterns.ITEM_BUTTON, parentId.getPath(), blockId.getPath());
} }
if (block.contains("pressed")) { if (block.contains("pressed")) {
return Patterned.createJson(Patterned.BLOCK_BUTTON_PRESSED, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BUTTON_PRESSED, parentId.getPath(), blockId.getPath());
} }
return Patterned.createJson(Patterned.BLOCK_BUTTON, parentId, blockId.getPath()); return Patterns.createJson(Patterns.BLOCK_BUTTON, parentId.getPath(), blockId.getPath());
} }
@Override @Override
public Identifier statePatternId() { public Identifier statePatternId() {
return Patterned.STATE_BUTTON; return Patterns.STATE_BUTTON;
} }
} }

View file

@ -3,6 +3,7 @@ package ru.betterend.mixin.client;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Optional;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -17,13 +18,15 @@ import net.minecraft.block.Block;
import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.json.JsonUnbakedModel; import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.render.model.json.ModelVariantMap.DeserializationContext; import net.minecraft.client.render.model.json.ModelVariantMap.DeserializationContext;
import net.minecraft.item.Item;
import net.minecraft.resource.Resource; import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.interfaces.IdentifiedContext; import ru.betterend.interfaces.IdentifiedContext;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.Patterned;
@Mixin(ModelLoader.class) @Mixin(ModelLoader.class)
public class ModelLoaderMixin { public class ModelLoaderMixin {
@ -50,21 +53,20 @@ public class ModelLoaderMixin {
} catch (Exception ex) { } catch (Exception ex) {
String data[] = id.getPath().split("/"); String data[] = id.getPath().split("/");
if (data.length > 1) { if (data.length > 1) {
Identifier blockId = new Identifier(id.getNamespace(), data[1]); Identifier itemId = new Identifier(id.getNamespace(), data[1]);
Block block = Registry.BLOCK.get(blockId); Optional<Block> block = Registry.BLOCK.getOrEmpty(itemId);
if (block instanceof Patterned) { if (block.isPresent()) {
String pattern; if (block.get() instanceof Patterned) {
if (id.getPath().contains("item")) { Patterned patterned = (Patterned) block.get();
pattern = ((Patterned) block).getModelPattern(id.getPath()); model = this.be_getModel(data, id, patterned);
} else { info.setReturnValue(model);
if (data.length > 2) { info.cancel();
pattern = ((Patterned) block).getModelPattern(data[2]);
} else {
pattern = ((Patterned) block).getModelPattern(data[1]);
} }
} } else {
model = JsonUnbakedModel.deserialize(pattern); Optional<Item> item = Registry.ITEM.getOrEmpty(itemId);
model.id = id.toString(); if (item.isPresent() && item.get() instanceof Patterned) {
Patterned patterned = (Patterned) item.get();
model = this.be_getModel(data, id, patterned);
info.setReturnValue(model); info.setReturnValue(model);
info.cancel(); info.cancel();
} }
@ -72,6 +74,24 @@ public class ModelLoaderMixin {
} }
} }
} }
}
private JsonUnbakedModel be_getModel(String data[], Identifier id, Patterned patterned) {
String pattern;
if (id.getPath().contains("item")) {
pattern = patterned.getModelPattern(id.getPath());
} else {
if (data.length > 2) {
pattern = patterned.getModelPattern(data[2]);
} else {
pattern = patterned.getModelPattern(data[1]);
}
}
JsonUnbakedModel model = JsonUnbakedModel.deserialize(pattern);
model.id = id.toString();
return model;
}
@Inject(method = "loadModel", at = @At( @Inject(method = "loadModel", at = @At(
value = "INVOKE", value = "INVOKE",

View file

@ -14,7 +14,7 @@ import net.minecraft.client.render.model.json.ModelVariantMap;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.interfaces.IdentifiedContext; import ru.betterend.interfaces.IdentifiedContext;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
@Mixin(ModelVariantMap.class) @Mixin(ModelVariantMap.class)
public abstract class ModelVariantMapMixin { public abstract class ModelVariantMapMixin {
@ -33,8 +33,8 @@ public abstract class ModelVariantMapMixin {
Identifier blockId = new Identifier(id.getNamespace(), data[1]); Identifier blockId = new Identifier(id.getNamespace(), data[1]);
Block block = Registry.BLOCK.get(blockId); Block block = Registry.BLOCK.get(blockId);
idContext.removeId(); idContext.removeId();
if (block instanceof Patterned) { if (block instanceof BlockPatterned) {
String pattern = ((Patterned) block).getStatesPattern(reader); String pattern = ((BlockPatterned) block).getStatesPattern(reader);
info.setReturnValue(deserialize(context, new StringReader(pattern))); info.setReturnValue(deserialize(context, new StringReader(pattern)));
info.cancel(); info.cancel();
} }

View file

@ -17,7 +17,7 @@ import net.minecraft.resource.Resource;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
import ru.betterend.interfaces.Patterned; import ru.betterend.patterns.BlockPatterned;
@Mixin(NamespaceResourceManager.class) @Mixin(NamespaceResourceManager.class)
public abstract class NamespaceResourceManagerMixin { public abstract class NamespaceResourceManagerMixin {
@ -35,9 +35,9 @@ public abstract class NamespaceResourceManagerMixin {
if (data.length > 1) { if (data.length > 1) {
Identifier blockId = BetterEnd.makeID(data[1].replace(".json", "")); Identifier blockId = BetterEnd.makeID(data[1].replace(".json", ""));
Block block = Registry.BLOCK.get(blockId); Block block = Registry.BLOCK.get(blockId);
if (block instanceof Patterned) { if (block instanceof BlockPatterned) {
List<Resource> resources = Lists.newArrayList(); List<Resource> resources = Lists.newArrayList();
resources.add(this.getResource(((Patterned) block).statePatternId())); resources.add(this.getResource(((BlockPatterned) block).statePatternId()));
info.setReturnValue(resources); info.setReturnValue(resources);
info.cancel(); info.cancel();
} }

View file

@ -0,0 +1,14 @@
package ru.betterend.patterns;
import java.io.Reader;
import net.minecraft.util.Identifier;
public interface BlockPatterned extends Patterned {
default String getStatesPattern(Reader data) {
return null;
}
default Identifier statePatternId() {
return null;
}
}

View file

@ -0,0 +1,7 @@
package ru.betterend.patterns;
public interface Patterned {
default String getModelPattern(String name) {
return null;
}
}

View file

@ -1,4 +1,4 @@
package ru.betterend.interfaces; package ru.betterend.patterns;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
@ -14,7 +14,8 @@ import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.BetterEnd; import ru.betterend.BetterEnd;
public interface Patterned { public class Patterns {
//Blockstates //Blockstates
public final static Identifier STATE_SIMPLE = BetterEnd.makeID("patterns/blockstate/pattern_block.json"); public final static Identifier STATE_SIMPLE = BetterEnd.makeID("patterns/blockstate/pattern_block.json");
public final static Identifier STATE_SLAB = BetterEnd.makeID("patterns/blockstate/pattern_slab.json"); public final static Identifier STATE_SLAB = BetterEnd.makeID("patterns/blockstate/pattern_slab.json");
@ -82,38 +83,22 @@ public interface Patterned {
public final static Identifier ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json"); public final static Identifier ITEM_BLOCK = BetterEnd.makeID("patterns/item/pattern_block_item.json");
public final static Identifier ITEM_MODEL = BetterEnd.makeID("patterns/item/pattern_item.json"); public final static Identifier ITEM_MODEL = BetterEnd.makeID("patterns/item/pattern_item.json");
default String getStatesPattern(Reader data) { public static String createJson(Reader data, String parent, String block) {
return null;
}
default String getModelPattern(String name) {
return null;
}
default Identifier statePatternId() {
return null;
}
default Identifier modelPatternId() {
return null;
}
public static String createJson(Reader data, Identifier parent, String name) {
try (BufferedReader buffer = new BufferedReader(data)) { try (BufferedReader buffer = new BufferedReader(data)) {
return buffer.lines().collect(Collectors.joining()) return buffer.lines().collect(Collectors.joining())
.replace("%parent%", parent.getPath()) .replace("%parent%", parent)
.replace("%block%", name); .replace("%block%", block);
} catch (Exception ex) { } catch (Exception ex) {
return null; return null;
} }
} }
public static String createJson(Identifier patternId, Identifier parent, String block) { public static String createJson(Identifier patternId, String parent, String block) {
ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager(); ResourceManager resourceManager = MinecraftClient.getInstance().getResourceManager();
try (InputStream input = resourceManager.getResource(patternId).getInputStream()) { try (InputStream input = resourceManager.getResource(patternId).getInputStream()) {
return new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)) return new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))
.lines().collect(Collectors.joining()) .lines().collect(Collectors.joining())
.replace("%parent%", parent.getPath()) .replace("%parent%", parent)
.replace("%block%", block); .replace("%block%", block);
} catch (Exception ex) { } catch (Exception ex) {
return null; return null;