@Override
  public void renderTileEntityAt(
      TileEntity te, double x, double y, double z, float partialTick, int destroyStage) {
    TileEntityCampfire campfire = (TileEntityCampfire) te;
    World world = te.getWorld();
    BlockPos pos = te.getPos();
    IBlockState state = world.getBlockState(pos);

    GlStateManager.pushMatrix();
    // Translate to the proper coordinates.
    GlStateManager.translate(x, y, z);

    EnumAxis axis = (EnumAxis) state.getValue(BlockCampfire.FACING);

    // Clear all rotation on the model parts before setting new rotation angles.
    model.fire.resetState();
    model.stick.resetState();
    model.cookingPot.resetState();
    model.stickItem.resetState();
    model.cookingItem.resetState();
    model.fuel.resetState();

    // Construct the proper ModelResourceLocation from STICK_LOC and the variant string.
    String properties = ModelHelpers.getPropertyString(state.getProperties());
    ModelResourceLocation stickLoc = ModelHelpers.getLocationWithProperties(STICK, properties);
    model.stick.setModelLocation(stickLoc, world, pos);

    boolean hasCookingPot = campfire.hasCookingPot();

    float stickRot = campfire.prevRot + (campfire.rot - campfire.prevRot) * partialTick;
    model.stick.rotateAngleZ += stickRot;

    if (axis == EnumAxis.Z) {
      model.stick.rotateAngleY += 90;
    }

    boolean burning = campfire.isBurning();

    // Set fire model location.
    if (burning) {
      model.fire.setModelLocation(
          ModelHelpers.getLocationWithProperties(FIRE, "fire=uncovered"), world, pos);
    } else if (campfire.isWet()) {
      if (fireModels.contains("wet")) {
        model.fire.setModelLocation(
            ModelHelpers.getLocationWithProperties(FIRE, "fire=wet"), world, pos);
      }
    } else {
      if (fireModels.contains("none")) {
        model.fire.setModelLocation(
            ModelHelpers.getLocationWithProperties(FIRE, "fire=none"), world, pos);
      }
    }

    if (hasCookingPot) {
      // Show only the cooking pot model.
      model.stickItem.showModel = false;
      model.cookingPot.showModel = true;

      model.cookingPot.setModelLocation(
          ModelHelpers.getLocationWithProperties(COOKING_POT, properties), world, pos);
    } else {
      ItemStack input = campfire.getInput();

      if (input != null) {
        String itemID = getVariantNameForCookingItem(input);

        if (itemID != null) {
          // Change fire model to a "covered" version so that it doesn't clip through the cooking
          // item.
          if (burning) {
            model.fire.setModelLocation(
                ModelHelpers.getLocationWithProperties(FIRE, "fire=covered"), world, pos);
          }

          model.cookingItem.setModelLocation(
              ModelHelpers.getLocationWithProperties(COOKING_ITEM, "item=" + itemID), world, pos);
        } else {
          // Show only the impaled item.
          model.stickItem.showModel = true;
          model.cookingPot.showModel = false;

          // Set the stack to render on the stick.
          model.stickItem.setStack(input);
          // Reset item's transformations.
          model.stickItem.rotateAngleX += 90;

          if (ModelHelpers.isGeneratedItemModel(input)) {
            // Offset the item to prevent Z-fighting.
            model.stickItem.offsetX -= 0.0001F;

            // Scale the item to half size.
            model.stickItem.scaleX *= 0.5F;
            model.stickItem.scaleY *= 0.5F;
            model.stickItem.scaleZ *= 0.5F;

            // Scale the item to be thicker, and actually appear to be impaled.
            model.stickItem.scaleZ *= 3;
          }
        }
      }
    }

    // Render a fuel model in the campfire (with possibility for custom models for individual
    // items).
    // Will try to fall back to variant "item=generic_fuel" if no model definition is found.
    ItemStack fuel = campfire.getFuel();

    if (fuel != null) {
      String itemID = ModelHelpers.getStringIDInSetForStack(fuel, fuelModels, "generic_fuel");

      if (itemID != null) {
        model.fuel.setModelLocation(
            ModelHelpers.getLocationWithProperties(FUEL, "item=" + itemID), world, pos);
      }
    }

    // Render the model.
    model.renderAll();

    GlStateManager.popMatrix();
  }