Change models loading (yes, WIP)

This commit is contained in:
Aleksey 2021-05-18 17:59:01 +03:00
parent 9b67bc5719
commit 52fc329a0a
8 changed files with 98 additions and 17 deletions

View file

@ -1,8 +1,11 @@
package ru.betterend.blocks.basis;
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.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
@ -19,6 +22,9 @@ import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import ru.betterend.blocks.BlockProperties;
import ru.betterend.client.models.ModelsHelper;
import java.util.Map;
public class EndLanternBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer {
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
@ -116,4 +122,13 @@ public class EndLanternBlock extends BlockBaseNotFull implements SimpleWaterlogg
public FluidState getFluidState(BlockState state) {
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
@Override
public MultiVariant getModelVariant(ResourceLocation resourceLocation, BlockState blockState, Map<ResourceLocation, UnbakedModel> modelCache) {
String floor = blockState.getValue(IS_FLOOR) ? "_floor" : "";
ResourceLocation modelId = new ResourceLocation(resourceLocation.getNamespace(),
"block/" + resourceLocation.getPath() + floor);
registerBlockModel(resourceLocation, modelId, blockState, modelCache);
return ModelsHelper.createBlockSimple(modelId);
}
}