Change models loading (still WIP)
This commit is contained in:
parent
2d23ca72ea
commit
744fe40a00
64 changed files with 437 additions and 269 deletions
|
@ -2,10 +2,10 @@ package ru.betterend.blocks.basis;
|
|||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -16,7 +16,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.client.models.BlockModelProvider;
|
||||
import ru.betterend.client.models.ModelsHelper;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
import ru.betterend.registry.EndBlockEntities;
|
||||
|
||||
|
@ -50,7 +49,7 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String path) {
|
||||
public Optional<String> getModelString(String path) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (path.contains("item")) {
|
||||
|
@ -61,8 +60,8 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
|||
|
||||
@Override
|
||||
public BlockModel getModel(ResourceLocation blockId) {
|
||||
String pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
|
||||
return BlockModel.fromString(pattern);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_CHEST, blockId.getPath());
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +72,7 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
|||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
||||
return BlockModel.fromString(pattern);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_EMPTY, parentId.getPath());
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue