use of net.minecraft.client.gui.ScaledResolution in project Witchworks by Um-Mitternacht.
the class BrewHUD method renderOverlay.
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
if (!BREW_HUD.hide && event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(Minecraft.getMinecraft().player);
if (optional.isPresent()) {
ScaledResolution res = event.getResolution();
int x = res.getScaledWidth() - BREW_HUD.x;
int yOffset = BREW_HUD.y;
Minecraft mc = Minecraft.getMinecraft();
Set<IBrew> client = optional.get().getClient();
if (client == null)
return;
Iterator<IBrew> renders = client.iterator();
GlStateManager.pushMatrix();
while (renders.hasNext()) {
renders.next().renderHUD(x, yOffset, mc);
yOffset += 22;
}
GlStateManager.popMatrix();
}
}
}
use of net.minecraft.client.gui.ScaledResolution in project Guide-API by TeamAmeriFrance.
the class EventHandler method renderOverlay.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Pre event) {
if (event.getType() != RenderGameOverlayEvent.ElementType.CROSSHAIRS)
return;
RayTraceResult rayTrace = Minecraft.getMinecraft().objectMouseOver;
if (rayTrace == null || rayTrace.typeOfHit != RayTraceResult.Type.BLOCK)
return;
EntityPlayer player = Minecraft.getMinecraft().player;
World world = Minecraft.getMinecraft().world;
ItemStack held = ItemStack.EMPTY;
Book book = null;
for (EnumHand hand : EnumHand.values()) {
ItemStack heldStack = player.getHeldItem(hand);
if (heldStack.getItem() instanceof IGuideItem) {
held = heldStack;
book = ((IGuideItem) heldStack.getItem()).getBook(heldStack);
break;
}
}
if (book == null)
return;
IBlockState state = world.getBlockState(rayTrace.getBlockPos());
String linkedEntry = null;
if (state.getBlock() instanceof IGuideLinked) {
IGuideLinked linked = (IGuideLinked) state.getBlock();
ResourceLocation entryKey = linked.getLinkedEntry(world, rayTrace.getBlockPos(), player, held);
if (entryKey != null) {
for (CategoryAbstract category : book.getCategoryList()) {
if (category.entries.containsKey(entryKey)) {
linkedEntry = category.getEntry(entryKey).getLocalizedName();
break;
}
}
}
}
if (!Strings.isNullOrEmpty(linkedEntry)) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int drawX = scaledResolution.getScaledWidth() / 2 + 10;
int drawY = scaledResolution.getScaledHeight() / 2 - 8;
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(held, drawX, drawY);
drawY -= 2;
drawX += 20;
fontRenderer.drawStringWithShadow(TextFormatting.WHITE + linkedEntry, drawX, drawY, 0);
fontRenderer.drawStringWithShadow(TextFormatting.WHITE.toString() + TextFormatting.ITALIC.toString() + TextHelper.localize("text.linked.open"), drawX, drawY + 12, 0);
}
if (state.getBlock() instanceof IInfoRenderer.Block) {
IInfoRenderer infoRenderer = ((IInfoRenderer.Block) state.getBlock()).getInfoRenderer(book, world, rayTrace.getBlockPos(), state, rayTrace, player);
if (book == ((IInfoRenderer.Block) state.getBlock()).getBook() && infoRenderer != null)
infoRenderer.drawInformation(book, world, rayTrace.getBlockPos(), state, rayTrace, player);
}
Multimap<Class<? extends Block>, IInfoRenderer> bookRenderers = GuideAPI.getInfoRenderers().get(book);
if (bookRenderers == null)
return;
Collection<IInfoRenderer> renderers = bookRenderers.get(state.getBlock().getClass());
for (IInfoRenderer renderer : renderers) renderer.drawInformation(book, world, rayTrace.getBlockPos(), state, rayTrace, player);
}
use of net.minecraft.client.gui.ScaledResolution in project Guide-API by TeamAmeriFrance.
the class InfoRendererImage method drawInformation.
@Override
public void drawInformation(Book book, World world, BlockPos pos, IBlockState state, RayTraceResult rayTrace, EntityPlayer player) {
ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft());
Minecraft.getMinecraft().renderEngine.bindTexture(image);
Gui.drawModalRectWithCustomSizedTexture(resolution.getScaledWidth() / 2 + 20, resolution.getScaledHeight() / 2 - imageHeight / 2, imageX, imageY, imageWidth, imageHeight, imageWidth, imageHeight);
}
use of net.minecraft.client.gui.ScaledResolution in project malmo by Microsoft.
the class ScreenHelper method onRenderTick.
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev) {
purgeExpiredFragments(null);
if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
return;
if (// Don't obscure MC debug info with our debug info
Minecraft.getMinecraft().gameSettings.showDebugInfo)
return;
ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
int width = res.getScaledWidth();
int height = res.getScaledHeight();
float rx = (float) width / 1000f;
float ry = (float) height / 1000f;
synchronized (this.fragments) {
for (TextCategory cat : TextCategory.values()) {
TextCategoryAttributes atts = this.attributes.get(cat);
if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel)) {
int x = Math.round(rx * (float) atts.xOrg);
int y = Math.round(ry * (float) atts.yOrg);
ArrayList<TextFragment> frags = this.fragments.get(cat);
if (frags != null && !frags.isEmpty()) {
for (TextFragment frag : frags) {
drawText(frag.text, x, y, atts.colour);
y += 10;
}
}
}
}
}
}
Aggregations