Ladder patterns

This commit is contained in:
Aleksey 2020-10-14 13:53:49 +03:00
parent 285addfc8b
commit d99f8225a8
48 changed files with 62 additions and 695 deletions

View file

@ -1,5 +1,7 @@
package ru.betterend.blocks.basis;
import java.io.Reader;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -15,17 +17,20 @@ import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.interfaces.Patterned;
import ru.betterend.util.BlocksHelper;
public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable {
public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable, Patterned {
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
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);
@ -45,15 +50,14 @@ public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable {
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
switch (state.get(FACING)) {
case NORTH:
return NORTH_SHAPE;
case SOUTH:
return SOUTH_SHAPE;
case WEST:
return WEST_SHAPE;
case EAST:
default:
return EAST_SHAPE;
default:
return NORTH_SHAPE;
}
}
@ -131,4 +135,24 @@ public class BlockLadder extends BlockBaseNotFull implements IRenderTypeable {
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
@Override
public String getStatesPattern(Reader data, String block) {
Identifier blockId = Registry.BLOCK.getId(this);
return Patterned.createJson(data, blockId, block);
}
@Override
public String getModelPattern(String block) {
Identifier blockId = Registry.BLOCK.getId(this);
if (block.contains("item")) {
return Patterned.createJson(Patterned.LADDER_ITEM_MODEL, blockId.getPath());
}
return Patterned.createJson(Patterned.LADDER_MODEL, blockId.getPath());
}
@Override
public Identifier statePatternId() {
return Patterned.LADDER_STATES_PATTERN;
}
}