Skip to content

Commit

Permalink
adds clipping to the mob view
Browse files Browse the repository at this point in the history
  • Loading branch information
way2muchnoise committed Jan 11, 2016
1 parent 64f9576 commit af4c8e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/jeresources/jei/mob/MobWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ public List<FluidStack> getFluidOutputs()
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight)
{
EntityLivingBase entityLivingBase = this.mob.getEntity();
RenderHelper.scissor(minecraft, recipeWidth, recipeHeight, 7, 58, 58, 78);
RenderHelper.renderEntity(
37, 110 - offsetY, scale,
RenderHelper.getLeft(minecraft, recipeWidth) + 38 - RenderHelper.getMousePosition().x,
RenderHelper.getTop(minecraft, recipeHeight) + 80 - offsetY - RenderHelper.getMousePosition().y,
entityLivingBase
);
RenderHelper.stopScissor();

Font.normal.print(this.mob.getMobName(), 7, 2);
Font.normal.print(TranslationHelper.translateToLocal("jer.mob.biome"), 7, 12);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/jeresources/utils/RenderHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ public static void renderBlock(IBlockState block, float x, float y, float z, flo
GlStateManager.disableRescaleNormal();
}

public static void scissor(Minecraft mc, int guiWidth, int guiHeight, float x, float y, int w, int h)
{
int scale = new ScaledResolution(mc).getScaleFactor();
x *= scale;
y *= scale;
w *= scale;
h *= scale;
float guiScaledWidth = (guiWidth * scale);
float guiScaledHeight = (guiHeight * scale);
float guiLeft = ((mc.displayWidth / 2) - guiScaledWidth / 2);
float guiTop = ((mc.displayHeight / 2) + guiScaledHeight / 2);
int scissorX = Math.round((guiLeft + x));
int scissorY = Math.round(((guiTop - h) - y));
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(scissorX, scissorY, w, h);
}

public static void stopScissor()
{
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}

private static RenderManager getRenderManager()
{
return Minecraft.getMinecraft().getRenderManager();
Expand Down

0 comments on commit af4c8e2

Please sign in to comment.