Change models loading (yes, still WIP)
This commit is contained in:
parent
52fc329a0a
commit
2ece809541
21 changed files with 122 additions and 51 deletions
|
@ -8,6 +8,7 @@ import com.google.common.collect.Maps;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -70,7 +71,7 @@ public class BulbVineLanternBlock extends EndLanternBlock implements IRenderType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
Map<String, String> textures = Maps.newHashMap();
|
Map<String, String> textures = Maps.newHashMap();
|
||||||
textures.put("%glow%", getGlowTexture());
|
textures.put("%glow%", getGlowTexture());
|
||||||
textures.put("%metal%", getMetalTexture(resourceLocation));
|
textures.put("%metal%", getMetalTexture(resourceLocation));
|
||||||
|
|
|
@ -32,7 +32,6 @@ public class BlockBase extends Block implements BlockModelProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation blockId) {
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
return getBlockModel(blockId, defaultBlockState());
|
return (BlockModel) getBlockModel(blockId, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -22,6 +21,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.blocks.BlockProperties;
|
import ru.betterend.blocks.BlockProperties;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
@ -77,11 +77,11 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation blockId) {
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
return getBlockModel(blockId, defaultBlockState());
|
return (BlockModel) getBlockModel(blockId, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
IntegerProperty destructionProperty = getDestructionProperty();
|
IntegerProperty destructionProperty = getDestructionProperty();
|
||||||
int destruction = blockState.getValue(destructionProperty);
|
int destruction = blockState.getValue(destructionProperty);
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
|
@ -93,7 +93,7 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
IntegerProperty destructionProperty = getDestructionProperty();
|
IntegerProperty destructionProperty = getDestructionProperty();
|
||||||
int destruction = blockState.getValue(destructionProperty);
|
int destruction = blockState.getValue(destructionProperty);
|
||||||
String modId = resourceLocation.getNamespace();
|
String modId = resourceLocation.getNamespace();
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -29,6 +28,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
import ru.betterend.blocks.entities.EBarrelBlockEntity;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
|
@ -104,11 +104,11 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation blockId) {
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
return getBlockModel(blockId, defaultBlockState());
|
return (BlockModel) getBlockModel(blockId, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
String texture = blockId.getPath();
|
String texture = blockId.getPath();
|
||||||
Optional<String> pattern;
|
Optional<String> pattern;
|
||||||
if (blockState.getValue(OPEN)) {
|
if (blockState.getValue(OPEN)) {
|
||||||
|
@ -120,7 +120,7 @@ public class EndBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
String open = blockState.getValue(OPEN) ? "_open" : "";
|
String open = blockState.getValue(OPEN) ? "_open" : "";
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath() + open);
|
"block/" + resourceLocation.getPath() + open);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -16,6 +17,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
public class EndBookshelfBlock extends BlockBase {
|
public class EndBookshelfBlock extends BlockBase {
|
||||||
|
@ -42,7 +44,7 @@ public class EndBookshelfBlock extends BlockBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_BOOKSHELF,
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_BOOKSHELF,
|
||||||
getName(blockId), blockId.getPath());
|
getName(blockId), blockId.getPath());
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -18,6 +17,7 @@ import net.minecraft.world.level.block.ChainBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -50,14 +50,14 @@ public class EndChainBlock extends ChainBlock implements BlockModelProvider, IRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
String name = blockId.getPath();
|
String name = blockId.getPath();
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CHAIN, name, name);
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
Direction.Axis axis = blockState.getValue(AXIS);
|
Direction.Axis axis = blockState.getValue(AXIS);
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath());
|
"block/" + resourceLocation.getPath());
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -14,6 +15,7 @@ import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
@ -58,7 +60,7 @@ public class EndChestBlock extends ChestBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
return ModelsHelper.createBlockEmpty(parentId);
|
return ModelsHelper.createBlockEmpty(parentId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -16,6 +15,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.ComposterBlock;
|
import net.minecraft.world.level.block.ComposterBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
|
@ -38,16 +38,16 @@ public class EndComposterBlock extends ComposterBlock implements BlockModelProvi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation resourceLocation) {
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
return getBlockModel(resourceLocation, defaultBlockState());
|
return (BlockModel) getBlockModel(resourceLocation, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -14,6 +15,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.CraftingTableBlock;
|
import net.minecraft.world.level.block.CraftingTableBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
|
@ -47,11 +49,11 @@ public class EndCraftingTableBlock extends CraftingTableBlock implements BlockMo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation resourceLocation) {
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
return getBlockModel(resourceLocation, defaultBlockState());
|
return (BlockModel) getBlockModel(resourceLocation, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
String blockName = blockId.getPath();
|
String blockName = blockId.getPath();
|
||||||
Optional<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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
@ -23,6 +23,7 @@ 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.DoorHingeSide;
|
||||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
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.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
|
@ -65,7 +66,7 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
String blockName = resourceLocation.getPath();
|
String blockName = resourceLocation.getPath();
|
||||||
DoorType doorType = getDoorType(blockState);
|
DoorType doorType = getDoorType(blockState);
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockName, blockName);
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_DOOR_BOTTOM, blockName, blockName);
|
||||||
|
@ -87,7 +88,7 @@ public class EndDoorBlock extends DoorBlock implements IRenderTypeable, BlockMod
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
Direction facing = blockState.getValue(FACING);
|
Direction facing = blockState.getValue(FACING);
|
||||||
DoorType doorType = getDoorType(blockState);
|
DoorType doorType = getDoorType(blockState);
|
||||||
boolean open = blockState.getValue(OPEN);
|
boolean open = blockState.getValue(OPEN);
|
||||||
|
|
|
@ -2,16 +2,29 @@ package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.mojang.math.Transformation;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.renderer.block.model.multipart.Condition;
|
||||||
|
import net.minecraft.client.renderer.block.model.multipart.MultiPart;
|
||||||
|
import net.minecraft.client.renderer.block.model.multipart.Selector;
|
||||||
|
import net.minecraft.client.resources.model.BlockModelRotation;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.FenceBlock;
|
import net.minecraft.world.level.block.FenceBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
|
||||||
|
@ -41,4 +54,57 @@ public class EndFenceBlock extends FenceBlock implements BlockModelProvider {
|
||||||
return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
|
return Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
|
Optional<String> pattern = Patterns.createJson(Patterns.ITEM_FENCE, parentId.getPath(), blockId.getPath());
|
||||||
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
|
ResourceLocation postId = new ResourceLocation(blockId.getNamespace(),
|
||||||
|
"block/" + blockId.getPath() + "_post");
|
||||||
|
ResourceLocation sideId = new ResourceLocation(blockId.getNamespace(),
|
||||||
|
"block/" + blockId.getPath() + "_side");
|
||||||
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
|
if (blockId.equals(postId)) {
|
||||||
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_FENCE_POST, parentId.getPath(), blockId.getPath());
|
||||||
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
|
}
|
||||||
|
if (blockId.equals(sideId)) {
|
||||||
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_FENCE_SIDE, parentId.getPath(), blockId.getPath());
|
||||||
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UnbakedModel getModelVariant(ResourceLocation blockId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
|
ResourceLocation postId = new ResourceLocation(blockId.getNamespace(),
|
||||||
|
"block/" + blockId.getPath() + "_post");
|
||||||
|
ResourceLocation sideId = new ResourceLocation(blockId.getNamespace(),
|
||||||
|
"block/" + blockId.getPath() + "_side");
|
||||||
|
registerBlockModel(blockId, postId, blockState, modelCache);
|
||||||
|
registerBlockModel(blockId, sideId, blockState, modelCache);
|
||||||
|
|
||||||
|
StateDefinition<Block, BlockState> blockStateDefinition = getStateDefinition();
|
||||||
|
MultiVariant postVariant = new MultiVariant(Lists.newArrayList(
|
||||||
|
new Variant(postId, Transformation.identity(), false, 1)));
|
||||||
|
MultiVariant sideNorth = new MultiVariant(Lists.newArrayList(
|
||||||
|
new Variant(sideId, Transformation.identity(), true, 1)));
|
||||||
|
MultiVariant sideEast = new MultiVariant(Lists.newArrayList(
|
||||||
|
new Variant(sideId, BlockModelRotation.X0_Y90.getRotation(), true, 1)));
|
||||||
|
MultiVariant sideSouth = new MultiVariant(Lists.newArrayList(
|
||||||
|
new Variant(sideId, BlockModelRotation.X0_Y180.getRotation(), true, 1)));
|
||||||
|
MultiVariant sideWest = new MultiVariant(Lists.newArrayList(
|
||||||
|
new Variant(sideId, BlockModelRotation.X0_Y270.getRotation(), true, 1)));
|
||||||
|
return new MultiPart(blockStateDefinition, Lists.newArrayList(
|
||||||
|
new Selector(Condition.TRUE, postVariant),
|
||||||
|
new Selector(stateDefinition -> state -> state.getValue(NORTH), sideNorth),
|
||||||
|
new Selector(stateDefinition -> state -> state.getValue(EAST), sideEast),
|
||||||
|
new Selector(stateDefinition -> state -> state.getValue(SOUTH), sideSouth),
|
||||||
|
new Selector(stateDefinition -> state -> state.getValue(WEST), sideWest)
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -26,6 +25,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
import ru.betterend.blocks.entities.EFurnaceBlockEntity;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
|
@ -70,7 +70,7 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
String blockName = blockId.getPath();
|
String blockName = blockId.getPath();
|
||||||
Map<String, String> textures = Maps.newHashMap();
|
Map<String, String> textures = Maps.newHashMap();
|
||||||
textures.put("%top%", blockName + "_top");
|
textures.put("%top%", blockName + "_top");
|
||||||
|
@ -89,11 +89,11 @@ public class EndFurnaceBlock extends FurnaceBlock implements BlockModelProvider,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation resourceLocation) {
|
public BlockModel getModel(ResourceLocation resourceLocation) {
|
||||||
return getBlockModel(resourceLocation, defaultBlockState());
|
return (BlockModel) getBlockModel(resourceLocation, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
String lit = blockState.getValue(LIT) ? "_lit" : "";
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath() + lit);
|
"block/" + resourceLocation.getPath() + lit);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ru.betterend.blocks.basis;
|
package ru.betterend.blocks.basis;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -124,7 +123,7 @@ public class EndLanternBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
String floor = blockState.getValue(IS_FLOOR) ? "_floor" : "";
|
String floor = blockState.getValue(IS_FLOOR) ? "_floor" : "";
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath() + floor);
|
"block/" + resourceLocation.getPath() + floor);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
import net.minecraft.client.renderer.block.model.MultiVariant;
|
|
||||||
import net.minecraft.client.resources.model.UnbakedModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -16,6 +15,7 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.BlockModelProvider;
|
import ru.betterend.client.models.BlockModelProvider;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.models.Patterns;
|
import ru.betterend.client.models.Patterns;
|
||||||
|
@ -36,7 +36,7 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation blockId) {
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
return getBlockModel(blockId, defaultBlockState());
|
return (BlockModel) getBlockModel(blockId, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,13 +46,13 @@ public class EndPillarBlock extends RotatedPillarBlock implements BlockModelProv
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
Optional<String> pattern = createBlockPattern(blockId);
|
Optional<String> pattern = createBlockPattern(blockId);
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath());
|
"block/" + resourceLocation.getPath());
|
||||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
@ -157,7 +157,7 @@ public class EndSignBlock extends SignBlock implements BlockModelProvider, ISpet
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
return ModelsHelper.createBlockEmpty(parentId);
|
return ModelsHelper.createBlockEmpty(parentId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,14 @@ public class EndSlabBlock extends SlabBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable BlockModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation blockId, BlockState blockState) {
|
||||||
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
ResourceLocation parentId = Registry.BLOCK.getKey(parent);
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_SLAB, parentId.getPath(), blockId.getPath());
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
SlabType type = blockState.getValue(TYPE);
|
SlabType type = blockState.getValue(TYPE);
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath() + "_" + type);
|
"block/" + resourceLocation.getPath() + "_" + type);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
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.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -26,6 +27,7 @@ import net.minecraft.world.level.material.Material;
|
||||||
import net.minecraft.world.level.storage.loot.LootContext;
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import ru.betterend.client.models.ModelsHelper;
|
import ru.betterend.client.models.ModelsHelper;
|
||||||
import ru.betterend.client.render.ERenderLayer;
|
import ru.betterend.client.render.ERenderLayer;
|
||||||
import ru.betterend.interfaces.IRenderTypeable;
|
import ru.betterend.interfaces.IRenderTypeable;
|
||||||
|
@ -123,7 +125,7 @@ public abstract class FeatureSaplingBlock extends SaplingBlock implements IRende
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_CROSS, resourceLocation.getPath());
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
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.client.resources.model.UnbakedModel;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -357,11 +356,11 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getModel(ResourceLocation blockId) {
|
public BlockModel getModel(ResourceLocation blockId) {
|
||||||
return getBlockModel(blockId, defaultBlockState());
|
return (BlockModel) getBlockModel(blockId, defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
Map<String, String> textures = createTexturesMap();
|
Map<String, String> textures = createTexturesMap();
|
||||||
PedestalState state = blockState.getValue(STATE);
|
PedestalState state = blockState.getValue(STATE);
|
||||||
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
Optional<String> pattern = Patterns.createJson(Patterns.BLOCK_PEDESTAL_DEFAULT, textures);
|
||||||
|
@ -391,7 +390,7 @@ public class PedestalBlock extends BlockBaseNotFull implements EntityBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
public UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
PedestalState state = blockState.getValue(STATE);
|
PedestalState state = blockState.getValue(STATE);
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath() + "_" + state);
|
"block/" + resourceLocation.getPath() + "_" + state);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.color.block.BlockColor;
|
import net.minecraft.client.color.block.BlockColor;
|
||||||
import net.minecraft.client.color.item.ItemColor;
|
import net.minecraft.client.color.item.ItemColor;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
|
import net.minecraft.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
|
@ -74,7 +75,7 @@ public class StoneLanternBlock extends EndLanternBlock implements IColorProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
public @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
String blockName = resourceLocation.getPath();
|
String blockName = resourceLocation.getPath();
|
||||||
Optional<String> pattern = blockState.getValue(IS_FLOOR) ?
|
Optional<String> pattern = blockState.getValue(IS_FLOOR) ?
|
||||||
Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, blockName, blockName) :
|
Patterns.createJson(Patterns.BLOCK_STONE_LANTERN_FLOOR, blockName, blockName) :
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package ru.betterend.client.models;
|
package ru.betterend.client.models;
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
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.client.resources.model.UnbakedModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
@ -15,13 +13,12 @@ import ru.betterend.BetterEnd;
|
||||||
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
import static net.minecraft.client.resources.model.ModelBakery.MISSING_MODEL_LOCATION;
|
||||||
|
|
||||||
public interface BlockModelProvider extends ModelProvider {
|
public interface BlockModelProvider extends ModelProvider {
|
||||||
@Nullable
|
default @Nullable UnbakedModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
||||||
default BlockModel getBlockModel(ResourceLocation resourceLocation, BlockState blockState) {
|
|
||||||
Optional<String> pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
Optional<String> pattern = Patterns.createBlockSimple(resourceLocation.getPath());
|
||||||
return pattern.map(BlockModel::fromString).orElse(null);
|
return pattern.map(BlockModel::fromString).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
default MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
default UnbakedModel getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
|
||||||
"block/" + resourceLocation.getPath());
|
"block/" + resourceLocation.getPath());
|
||||||
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
|
||||||
|
@ -30,7 +27,7 @@ public interface BlockModelProvider extends ModelProvider {
|
||||||
|
|
||||||
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
default void registerBlockModel(ResourceLocation stateId, ResourceLocation modelId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
|
||||||
if (!modelCache.containsKey(modelId)) {
|
if (!modelCache.containsKey(modelId)) {
|
||||||
BlockModel model = getBlockModel(stateId, blockState);
|
UnbakedModel model = getBlockModel(stateId, blockState);
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
modelCache.put(modelId, model);
|
modelCache.put(modelId, model);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -79,7 +79,7 @@ public abstract class ModelLoaderMixin {
|
||||||
.filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state)))
|
.filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state)))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
if (stateOptional.isPresent()) {
|
if (stateOptional.isPresent()) {
|
||||||
MultiVariant modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, stateOptional.get(), unbakedCache);
|
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, stateOptional.get(), unbakedCache);
|
||||||
if (modelVariant != null) {
|
if (modelVariant != null) {
|
||||||
cacheAndQueueDependencies(modelId, modelVariant);
|
cacheAndQueueDependencies(modelId, modelVariant);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue