Made Path class abstract

This commit is contained in:
Aleksey 2021-05-27 22:02:26 +03:00
parent 5da667261c
commit e0b45ee833
2 changed files with 7 additions and 7 deletions

View file

@ -8,7 +8,7 @@ yarn_mappings=6
loader_version=0.11.3 loader_version=0.11.3
# Mod Properties # Mod Properties
mod_version = 0.1.9 mod_version = 0.1.10
maven_group = ru.bclib maven_group = ru.bclib
archives_base_name = bclib archives_base_name = bclib

View file

@ -30,14 +30,11 @@ import ru.bclib.client.models.BasePatterns;
import ru.bclib.client.models.ModelsHelper; import ru.bclib.client.models.ModelsHelper;
import ru.bclib.client.models.PatternsHelper; import ru.bclib.client.models.PatternsHelper;
public class BasePathBlock extends BaseBlockNotFull { public abstract class BasePathBlock extends BaseBlockNotFull {
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16); private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
private final Block base;
public BasePathBlock(Block source) { public BasePathBlock(Block source) {
super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; })); super(FabricBlockSettings.copyOf(source).isValidSpawn((state, world, pos, type) -> { return false; }));
this.base = source;
if (source instanceof BaseTerrainBlock) { if (source instanceof BaseTerrainBlock) {
BaseTerrainBlock terrain = (BaseTerrainBlock) source; BaseTerrainBlock terrain = (BaseTerrainBlock) source;
terrain.setPathBlock(this); terrain.setPathBlock(this);
@ -71,8 +68,9 @@ public class BasePathBlock extends BaseBlockNotFull {
@Override @Override
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) { public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
String name = resourceLocation.getPath(); String name = resourceLocation.getPath();
ResourceLocation baseId = Registry.BLOCK.getKey(base); Block bottomBlock = getBottomBlock();
String bottom = baseId.getNamespace() + ":block/" + baseId.getPath(); ResourceLocation bottomId = Registry.BLOCK.getKey(bottomBlock);
String bottom = bottomId.getNamespace() + ":block/" + bottomId.getPath();
Map<String, String> textures = Maps.newHashMap(); Map<String, String> textures = Maps.newHashMap();
textures.put("%modid%", resourceLocation.getNamespace()); textures.put("%modid%", resourceLocation.getNamespace());
textures.put("%top%", name + "_top"); textures.put("%top%", name + "_top");
@ -88,4 +86,6 @@ public class BasePathBlock extends BaseBlockNotFull {
registerBlockModel(stateId, modelId, blockState, modelCache); registerBlockModel(stateId, modelId, blockState, modelCache);
return ModelsHelper.createRandomTopModel(modelId); return ModelsHelper.createRandomTopModel(modelId);
} }
protected abstract Block getBottomBlock();
} }