Guest User

FrameBakedModel

a guest
Oct 15th, 2020
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class FrameBakedModel implements IDynamicBakedModel {
  2.     public static final ResourceLocation TEXTURE = new ResourceLocation("minecraft", "block/oak_planks");
  3.  
  4.     private TextureAtlasSprite getTexture() {
  5.         return Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(TEXTURE);
  6.     }
  7.  
  8.     @Nonnull
  9.     @Override
  10.     public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
  11.  
  12.         BlockState mimic = extraData.getData(FrameBlockTile.MIMIC);
  13.         Integer design = extraData.getData(FrameBlockTile.DESIGN);
  14.         Integer desTex = extraData.getData(FrameBlockTile.DESIGN_TEXTURE);
  15.         if (side != null) {
  16.             return Collections.emptyList();
  17.         }
  18.         if (mimic != null && !(mimic.getBlock() instanceof FrameBlock)) {
  19.             ModelResourceLocation location = BlockModelShapes.getModelLocation(mimic);
  20.             if (location != null && state != null) {
  21.                 IBakedModel model = Minecraft.getInstance().getModelManager().getModel(location);
  22.                 if (model != null) {
  23.                     List<TextureAtlasSprite> textureList = TextureHelper.getTextureFromModel(model, extraData, rand);
  24.                     TextureAtlasSprite texture;
  25.                     Integer tex = extraData.getData(FrameBlockTile.TEXTURE);
  26.                     if (textureList.size() <= tex) {
  27.                         extraData.setData(FrameBlockTile.TEXTURE, 0);
  28.                         tex = 0;
  29.                     }
  30.                     if (textureList.size() == 0) {
  31.                         if (Minecraft.getInstance().player != null) {
  32.                             Minecraft.getInstance().player.sendStatusMessage(new TranslationTextComponent("We're sorry, but this block can't be displayed"), true);
  33.                         }
  34.                         return Collections.emptyList();
  35.                     }
  36.                     texture = textureList.get(tex);
  37.                     int tintIndex = -1;
  38.                     if (mimic.getBlock() instanceof GrassBlock) {
  39.                         tintIndex = 1;
  40.                     }
  41.                     List<BakedQuad> quads = new ArrayList<>(ModelHelper.createCuboid(0f, 1f, 0f, 1f, 0f, 1f, texture, tintIndex));
  42.                     int overlayIndex = extraData.getData(FrameBlockTile.OVERLAY);
  43.                     if (overlayIndex != 0) {
  44.                         quads.addAll(ModelHelper.createOverlay(0f, 1f, 0f, 1f, 0f, 1f, overlayIndex));
  45.                     }
  46.                     return quads;
  47.                 }
  48.             }
  49.         }
  50.         return Collections.emptyList();
  51.     }
  52.  
  53.     @Override
  54.     public boolean isAmbientOcclusion() {
  55.         return true;
  56.     }
  57.  
  58.     @Override
  59.     public boolean isGui3d() {
  60.         return false;
  61.     }
  62.  
  63.     @Override
  64.     public boolean func_230044_c_() {
  65.         return false;
  66.     }
  67.  
  68.     @Override
  69.     public boolean isBuiltInRenderer() {
  70.         return false;
  71.     }
  72.  
  73.     @Override
  74.     public TextureAtlasSprite getParticleTexture() {
  75.         return getTexture();
  76.     }
  77.  
  78.     @Override
  79.     public ItemOverrideList getOverrides() {
  80.         return ItemOverrideList.EMPTY;
  81.     }
  82.  
  83.     @Override
  84.     public ItemCameraTransforms getItemCameraTransforms() {
  85.         return ItemCameraTransforms.DEFAULT;
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment