Change models loading (still WIP)
This commit is contained in:
parent
2d23ca72ea
commit
744fe40a00
64 changed files with 437 additions and 269 deletions
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -18,7 +19,7 @@ public class BarkBlock extends EndPillarBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String createBlockPattern(ResourceLocation blockId) {
|
||||
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
|
||||
blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -31,7 +32,7 @@ public class BlockBase extends Block implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createBlockSimple(blockId.getPath());
|
||||
}
|
||||
|
|
|
@ -4,12 +4,14 @@ import java.io.Reader;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
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.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -38,7 +40,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
|||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
super.createBlockStateDefinition(builder);
|
||||
builder.add(DESTRUCTION);
|
||||
builder.add(getDestructionProperty());
|
||||
}
|
||||
|
||||
public IntegerProperty getDestructionProperty() {
|
||||
|
@ -64,7 +66,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%anvil%", blockId.getPath());
|
||||
|
@ -98,19 +100,18 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
|||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%anvil%", name);
|
||||
textures.put("%top%", name + "_top_" + destruction);
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
|
||||
return BlockModel.fromString(pattern);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_ANVIL, textures);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
IntegerProperty destructionProperty = getDestructionProperty();
|
||||
int destruction = blockState.getValue(destructionProperty);
|
||||
String modId = resourceLocation.getNamespace();
|
||||
String modelId = "block/" + resourceLocation.getPath() + "_top_" + destruction;
|
||||
ResourceLocation modelLocation = new ResourceLocation(modId, modelId);
|
||||
System.out.println(modelLocation);
|
||||
ModelsHelper.addBlockState(blockState, modelLocation);
|
||||
registerBlockModel(resourceLocation, modelLocation, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelLocation, blockState.getValue(FACING).getOpposite());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@ package ru.betterend.blocks.basis;
|
|||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
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.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -99,7 +101,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("open")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||
|
@ -120,24 +122,21 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
|||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String texture = blockId.getPath();
|
||||
String pattern;
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(OPEN)) {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BARREL_OPEN, texture, texture);
|
||||
} else {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_BOTTOM_TOP, texture, texture);
|
||||
}
|
||||
if (pattern != null) {
|
||||
return BlockModel.fromString(pattern);
|
||||
}
|
||||
return null;
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath() + open);
|
||||
ModelsHelper.addBlockState(blockState, modelId);
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
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.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -40,7 +42,7 @@ public class EndBookshelfBlock extends BlockBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BOOKSHELF, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
@ -50,7 +52,14 @@ public class EndBookshelfBlock extends BlockBase {
|
|||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(data, getName(blockId), blockId.getPath());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_BOOKSHELF,
|
||||
getName(blockId), blockId.getPath());
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
private String getName(ResourceLocation blockId) {
|
||||
String name = blockId.getPath();
|
||||
return name.replace("_bookshelf", "");
|
||||
|
|
|
@ -3,10 +3,13 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -40,7 +43,7 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createItemGenerated(block);
|
||||
|
@ -61,18 +64,16 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
|
|||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String name = blockId.getPath();
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
||||
if (pattern != null) {
|
||||
return BlockModel.fromString(pattern);
|
||||
}
|
||||
return null;
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
Direction.Axis axis = blockState.getValue(AXIS);
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath());
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRotatedModel(modelId, axis);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,13 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -34,7 +37,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockModelProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
String blockName = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_COMPOSTER, blockName);
|
||||
|
@ -56,7 +59,7 @@ public class EndComposterBlock extends ComposterBlock implements BlockModelProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ import java.io.Reader;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
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.CraftingTableBlock;
|
|||
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;
|
||||
|
||||
public class EndCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
||||
|
@ -36,7 +35,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
String blockName = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
|
@ -66,7 +65,7 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
|
|||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
String blockName = blockId.getPath();
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SIDED, new HashMap<String, String>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
{
|
||||
put("%particle%", blockName + "_front");
|
||||
|
@ -78,6 +77,6 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
|
|||
put("%east%", blockName + "_side");
|
||||
}
|
||||
});
|
||||
return BlockModel.fromString(pattern);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,14 +3,25 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
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.client.renderer.block.model.Variant;
|
||||
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.StringRepresentable;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import ru.betterend.client.render.ERenderLayer;
|
||||
|
@ -41,9 +52,9 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
|
|||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(data, blockId, blockId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, block);
|
||||
|
@ -59,9 +70,127 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
|
|||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockId, blockId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String blockName = resourceLocation.getPath();
|
||||
DoorType doorType = getDoorType(blockState);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockName, blockName);
|
||||
switch (doorType) {
|
||||
case TOP_HINGE: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP_HINGE, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
case BOTTOM_HINGE: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM_HINGE, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
case TOP: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_DOOR_TOP, blockName, blockName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
DoorType doorType = getDoorType(blockState);
|
||||
boolean open = blockState.getValue(OPEN);
|
||||
boolean hinge = doorType.isHinge();
|
||||
BlockModelRotation rotation = BlockModelRotation.X0_Y0;
|
||||
switch (facing) {
|
||||
case EAST: {
|
||||
if (hinge && open) {
|
||||
rotation = BlockModelRotation.by(0, 90);
|
||||
} else if (open) {
|
||||
rotation = BlockModelRotation.by(0, 270);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.by(0, 90);
|
||||
} else if (hinge) {
|
||||
rotation = BlockModelRotation.by(0, 180);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.by(0, 180);
|
||||
} else if (hinge) {
|
||||
rotation = BlockModelRotation.by(0, 270);
|
||||
} else {
|
||||
rotation = BlockModelRotation.by(0, 90);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
if (!hinge && !open || hinge && !open) {
|
||||
rotation = BlockModelRotation.by(0, 270);
|
||||
} else if (!hinge) {
|
||||
rotation = BlockModelRotation.by(0, 180);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath() + "_" + doorType);
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
Variant variant = new Variant(modelId, rotation.getRotation(), false, 1);
|
||||
return new MultiVariant(Lists.newArrayList(variant));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation statePatternId() {
|
||||
return Patterns.STATE_DOOR;
|
||||
}
|
||||
|
||||
protected DoorType getDoorType(BlockState blockState) {
|
||||
boolean isHinge = isHinge(blockState.getValue(HINGE), blockState.getValue(OPEN));
|
||||
switch (blockState.getValue(HALF)) {
|
||||
case UPPER: {
|
||||
return isHinge ? DoorType.TOP_HINGE : DoorType.TOP;
|
||||
}
|
||||
case LOWER: {
|
||||
return isHinge ? DoorType.BOTTOM_HINGE : DoorType.BOTTOM;
|
||||
}
|
||||
}
|
||||
return DoorType.BOTTOM;
|
||||
}
|
||||
|
||||
private boolean isHinge(DoorHingeSide hingeSide, boolean open) {
|
||||
boolean isHinge = hingeSide == DoorHingeSide.RIGHT;
|
||||
return isHinge && !open || !isHinge && open;
|
||||
}
|
||||
|
||||
protected enum DoorType implements StringRepresentable {
|
||||
BOTTOM_HINGE("bottom_hinge"),
|
||||
TOP_HINGE("top_hinge"),
|
||||
BOTTOM("bottom"),
|
||||
TOP("top");
|
||||
|
||||
private final String name;
|
||||
|
||||
DoorType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isHinge() {
|
||||
return this == BOTTOM_HINGE ||
|
||||
this == TOP_HINGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getSerializedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerializedName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -10,8 +11,8 @@ import com.google.common.collect.Maps;
|
|||
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.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.stats.Stats;
|
||||
|
@ -59,7 +60,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%top%", blockId.getPath() + "_top");
|
||||
|
@ -86,7 +87,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
|||
Map<String, String> textures = Maps.newHashMap();
|
||||
textures.put("%top%", blockName + "_top");
|
||||
textures.put("%side%", blockName + "_side");
|
||||
String pattern;
|
||||
Optional<String> pattern;
|
||||
if (blockState.getValue(LIT)) {
|
||||
textures.put("%front%", blockName + "_front_on");
|
||||
textures.put("%glow%", blockName + "_glow");
|
||||
|
@ -95,7 +96,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
|||
textures.put("%front%", blockName + "_front");
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_FURNACE, textures);
|
||||
}
|
||||
return BlockModel.fromString(pattern);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,11 +105,11 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath() + lit);
|
||||
ModelsHelper.addBlockState(blockState, modelId);
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createFacingModel(modelId, blockState.getValue(FACING));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndGateBlock extends FenceGateBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("wall")) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -144,7 +145,7 @@ public class EndLadderBlock extends BlockBaseNotFull implements IRenderTypeable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class EndLeavesBlock extends LeavesBlock implements BlockModelProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String blockId = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId, blockId);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -37,7 +38,7 @@ public class EndMetalPaneBlock extends IronBarsBlock implements BlockModelProvid
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, blockId.getPath());
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndMetalPlateBlock extends WeightedPressurePlateBlock implements Bl
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("down")) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -78,7 +79,7 @@ public class EndOreBlock extends OreBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, blockId.getPath(), block);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.Direction;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -45,7 +47,7 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
return createBlockPattern(blockId);
|
||||
}
|
||||
|
@ -57,18 +59,19 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
|||
|
||||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||
return BlockModel.fromString(createBlockPattern(blockId));
|
||||
Optional<String> pattern = createBlockPattern(blockId);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath());
|
||||
ModelsHelper.addBlockState(blockState, modelId);
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createRotatedModel(modelId, blockState.getValue(AXIS));
|
||||
}
|
||||
|
||||
protected String createBlockPattern(ResourceLocation blockId) {
|
||||
protected Optional<String> createBlockPattern(ResourceLocation blockId) {
|
||||
return Patterns.createBlockPillar(blockId.getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndPlateBlock extends PressurePlateBlock implements BlockModelProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("down")) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -152,7 +153,7 @@ public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpet
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String path) {
|
||||
public Optional<String> getModelString(String path) {
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (path.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, path);
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
return Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -37,16 +38,17 @@ public class EndStairsBlock extends StairBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
|
||||
if (block.contains("inner")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_INNER, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
if (block.contains("outer")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_STAIR_OUTER, parentId.getPath(), blockId.getPath());
|
||||
}
|
||||
return Patterns.createJson(Patterns.BLOCK_STAIR, parentId.getPath(), blockId.getPath());
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndStoneButtonBlock extends StoneButtonBlock implements BlockModelP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.Reader;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -40,7 +41,7 @@ public class EndTrapdoorBlock extends TrapDoorBlock implements IRenderTypeable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
String name = blockId.getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_TRAPDOOR, new HashMap<String, String>() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -37,7 +38,7 @@ public class EndWallBlock extends WallBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -36,7 +37,7 @@ public class EndWoodenButtonBlock extends WoodButtonBlock implements BlockModelP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||
if (block.contains("item")) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package ru.betterend.blocks.basis;
|
|||
import java.io.Reader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
@ -116,7 +117,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
if (block.contains("item")) {
|
||||
block = block.split("/")[1];
|
||||
return Patterns.createJson(Patterns.ITEM_BLOCK, block);
|
||||
|
@ -136,7 +137,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
|||
|
||||
@Override
|
||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
|
||||
return BlockModel.fromString(pattern);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ import java.io.Reader;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -344,7 +346,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
Map<String, String> textures = createTexturesMap();
|
||||
if (block.contains("column_top")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
|
@ -369,7 +371,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
|||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
Map<String, String> textures = createTexturesMap();
|
||||
PedestalState state = blockState.getValue(STATE);
|
||||
String pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||
switch (state) {
|
||||
case COLUMN_TOP: {
|
||||
pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_COLUMN_TOP, textures);
|
||||
|
@ -392,15 +394,16 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return BlockModel.fromString(pattern);
|
||||
return pattern.map(BlockModel::fromString).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState) {
|
||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||
PedestalState state = blockState.getValue(STATE);
|
||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||
"block/" + resourceLocation.getPath() + "_" + state);
|
||||
return super.getModelVariant(modelId, blockState);
|
||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||
return ModelsHelper.createBlockSimple(modelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -43,7 +44,7 @@ public class SimpleLeavesBlock extends BlockBaseNotFull implements IRenderTypeab
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, texture, texture);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import ru.betterend.client.render.ERenderLayer;
|
|||
import ru.betterend.interfaces.IRenderTypeable;
|
||||
import ru.betterend.client.models.Patterns;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTypeable {
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
|
||||
|
@ -192,7 +194,7 @@ public class StalactiteBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
if (block.contains("item")) {
|
||||
return Patterns.createJson(Patterns.ITEM_GENERATED, "item/" + blockId.getPath());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
|
@ -68,7 +69,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String texture = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.contains("ceil")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_CEIL, texture, texture);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ru.betterend.blocks.basis;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -49,7 +50,7 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getModelString(String block) {
|
||||
public Optional<String> getModelString(String block) {
|
||||
String name = Registry.BLOCK.getKey(this).getPath();
|
||||
if (block.endsWith("_middle")) {
|
||||
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue