use of net.minecraft.client.renderer.block.model.MultiVariant in project BCLib by paulevsGitch.
the class TripleTerrainBlock method getModelVariant.
@Override
@Environment(EnvType.CLIENT)
public UnbakedModel getModelVariant(ResourceLocation stateId, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
boolean isMiddle = isMiddle(blockState);
String middle = isMiddle ? "_middle" : "";
ResourceLocation modelId = new ResourceLocation(stateId.getNamespace(), "block/" + stateId.getPath() + middle);
registerBlockModel(stateId, modelId, blockState, modelCache);
if (isMiddle) {
List<Variant> variants = Lists.newArrayList();
for (BlockModelRotation rotation : BlockModelRotation.values()) {
variants.add(new Variant(modelId, rotation.getRotation(), false, 1));
}
return new MultiVariant(variants);
} else if (blockState.getValue(SHAPE) == TripleShape.TOP) {
return new MultiVariant(Lists.newArrayList(new Variant(modelId, BlockModelRotation.X180_Y0.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y90.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y180.getRotation(), false, 1), new Variant(modelId, BlockModelRotation.X180_Y270.getRotation(), false, 1)));
}
return ModelsHelper.createRandomTopModel(modelId);
}
use of net.minecraft.client.renderer.block.model.MultiVariant in project excavated_variants by lukebemish.
the class BlockStateAssembler method getInfoFromBlockstate.
private static Pair<BlockModelDefinition, List<ResourceLocation>> getInfoFromBlockstate(ResourceLocation oreRl, BlockModelDefinition.Context ctx) throws IOException {
ResourceLocation oreBS = new ResourceLocation(oreRl.getNamespace(), "blockstates/" + oreRl.getPath() + ".json");
InputStream oreBSIS;
try {
oreBSIS = ClientPrePackRepository.getResource(oreBS);
} catch (IOException e) {
oreBSIS = BackupFetcher.provideBlockstateFile(oreRl);
}
BlockModelDefinition oreBMD = BlockModelDefinition.fromStream(ctx, new BufferedReader(new InputStreamReader(oreBSIS, StandardCharsets.UTF_8)));
if (!oreBMD.isMultiPart()) {
Set<ResourceLocation> oreModels = new HashSet<>();
for (Map.Entry<String, MultiVariant> e : oreBMD.getVariants().entrySet()) {
oreModels.addAll(e.getValue().getDependencies());
}
List<ResourceLocation> oreTextures = new ArrayList<>();
for (ResourceLocation mRl : oreModels) {
ResourceLocation actual = new ResourceLocation(mRl.getNamespace(), "models/" + mRl.getPath() + ".json");
InputStream is;
try {
is = ClientPrePackRepository.getResource(actual);
} catch (IOException e) {
is = BackupFetcher.provideBlockModelFile(mRl);
}
BlockModelParser map = GSON.fromJson(new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)), BlockModelParser.class);
if (map.textures != null) {
for (String i : map.textures.values()) {
ResourceLocation o = ResourceLocation.of(i, ':');
oreTextures.add(new ResourceLocation(o.getNamespace(), "textures/" + o.getPath() + ".png"));
}
}
}
return new Pair<>(oreBMD, oreTextures);
}
return null;
}
Aggregations