Change loading models (WIP)
This commit is contained in:
parent
6447ec6026
commit
de8baa4b83
5 changed files with 34 additions and 20 deletions
|
@ -24,6 +24,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.patterns.BlockModelProvider;
|
||||
|
@ -94,20 +95,34 @@ public class EndAnvilBlock extends AnvilBlock implements BlockModelProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Triple<ResourceLocation, MultiVariant, BlockModel> getBlockModels(BlockState blockState) {
|
||||
public Pair<ResourceLocation, BlockModel> getBlockModel(BlockState blockState) {
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
int destruction = blockState.getValue(DESTRUCTION);
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation modelId = new ResourceLocation(blockId.getNamespace(),
|
||||
blockId.getPath() + "/" + facing + "/destruction_" + destruction);
|
||||
Transformation transform = new Transformation(null, facing.getRotation(), null, null);
|
||||
Variant variant = new Variant(modelId, transform, false, 1);
|
||||
MultiVariant weightedModel = new MultiVariant(Collections.singletonList(variant));
|
||||
ResourceLocation modelId = createModelId(blockId, facing, destruction);
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("%anvil%", blockId.getPath());
|
||||
map.put("%top%", "_top_" + destruction);
|
||||
String jsonString = Patterns.createJson(Patterns.BLOCK_ANVIL, map);
|
||||
BlockModel blockModel = BlockModel.fromString(jsonString);
|
||||
return Triple.of(modelId, weightedModel, blockModel);
|
||||
|
||||
return Pair.of(modelId, blockModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiVariant getModelVariant(BlockState blockState) {
|
||||
Direction facing = blockState.getValue(FACING);
|
||||
int destruction = blockState.getValue(DESTRUCTION);
|
||||
ResourceLocation blockId = Registry.BLOCK.getKey(this);
|
||||
ResourceLocation modelId = createModelId(blockId, facing, destruction);
|
||||
Transformation transform = new Transformation(null, facing.getRotation(), null, null);
|
||||
Variant variant = new Variant(modelId, transform, false, 1);
|
||||
|
||||
return new MultiVariant(Collections.singletonList(variant));
|
||||
}
|
||||
|
||||
protected ResourceLocation createModelId(ResourceLocation blockId, Direction facing, int destruction) {
|
||||
return new ResourceLocation(blockId.getNamespace(),
|
||||
blockId.getPath() + "/" + facing + "/destruction_" + destruction);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue