Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RenderCrystal extends TileEntitySpecialRenderer<TileCrystal>
- {
- private IBakedModel baked;
- private IBakedModel getBakedModel()
- {
- IModel model;
- if (baked == null) {
- try
- {
- model = ModelLoaderRegistry.getModel(new ResourceLocation(PMCore.ModId, "block/crystal.obj"));
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- baked = model.bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()));
- }
- return baked;
- }
- @Override
- public void renderTileEntityAt(TileCrystal te, double x, double y, double z, float partialTicks, int destroyStage) {
- GlStateManager.pushAttrib();
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, z);
- renderModel(te);
- GlStateManager.popMatrix();
- GlStateManager.popAttrib();
- }
- private void renderModel(TileCrystal te) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0.5, 0, 0.5);
- RenderHelper.disableStandardItemLighting();
- this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
- if (Minecraft.isAmbientOcclusionEnabled()) {
- GlStateManager.shadeModel(GL11.GL_SMOOTH);
- } else {
- GlStateManager.shadeModel(GL11.GL_FLAT);
- }
- World world = te.getWorld();
- GlStateManager.translate(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
- Tessellator tessellator = Tessellator.getInstance();
- tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
- Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(
- world,
- getBakedModel(),
- world.getBlockState(te.getPos()),
- te.getPos(),
- Tessellator.getInstance().getBuffer(),
- true);
- tessellator.draw();
- RenderHelper.enableStandardItemLighting();
- GlStateManager.popMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment