Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FrameBakedModel implements IDynamicBakedModel {
- public static final ResourceLocation TEXTURE = new ResourceLocation("minecraft", "block/oak_planks");
- private TextureAtlasSprite getTexture() {
- return Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(TEXTURE);
- }
- @Nonnull
- @Override
- public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
- BlockState mimic = extraData.getData(FrameBlockTile.MIMIC);
- Integer design = extraData.getData(FrameBlockTile.DESIGN);
- Integer desTex = extraData.getData(FrameBlockTile.DESIGN_TEXTURE);
- if (side != null) {
- return Collections.emptyList();
- }
- if (mimic != null && !(mimic.getBlock() instanceof FrameBlock)) {
- ModelResourceLocation location = BlockModelShapes.getModelLocation(mimic);
- if (location != null && state != null) {
- IBakedModel model = Minecraft.getInstance().getModelManager().getModel(location);
- if (model != null) {
- List<TextureAtlasSprite> textureList = TextureHelper.getTextureFromModel(model, extraData, rand);
- TextureAtlasSprite texture;
- Integer tex = extraData.getData(FrameBlockTile.TEXTURE);
- if (textureList.size() <= tex) {
- extraData.setData(FrameBlockTile.TEXTURE, 0);
- tex = 0;
- }
- if (textureList.size() == 0) {
- if (Minecraft.getInstance().player != null) {
- Minecraft.getInstance().player.sendStatusMessage(new TranslationTextComponent("We're sorry, but this block can't be displayed"), true);
- }
- return Collections.emptyList();
- }
- texture = textureList.get(tex);
- int tintIndex = -1;
- if (mimic.getBlock() instanceof GrassBlock) {
- tintIndex = 1;
- }
- List<BakedQuad> quads = new ArrayList<>(ModelHelper.createCuboid(0f, 1f, 0f, 1f, 0f, 1f, texture, tintIndex));
- int overlayIndex = extraData.getData(FrameBlockTile.OVERLAY);
- if (overlayIndex != 0) {
- quads.addAll(ModelHelper.createOverlay(0f, 1f, 0f, 1f, 0f, 1f, overlayIndex));
- }
- return quads;
- }
- }
- }
- return Collections.emptyList();
- }
- @Override
- public boolean isAmbientOcclusion() {
- return true;
- }
- @Override
- public boolean isGui3d() {
- return false;
- }
- @Override
- public boolean func_230044_c_() {
- return false;
- }
- @Override
- public boolean isBuiltInRenderer() {
- return false;
- }
- @Override
- public TextureAtlasSprite getParticleTexture() {
- return getTexture();
- }
- @Override
- public ItemOverrideList getOverrides() {
- return ItemOverrideList.EMPTY;
- }
- @Override
- public ItemCameraTransforms getItemCameraTransforms() {
- return ItemCameraTransforms.DEFAULT;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment