Java Code Examples for net.minecraft.client.Minecraft#getSystemTime()

The following examples show how to use net.minecraft.client.Minecraft#getSystemTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiConfig.java    From CraftingKeys with MIT License 6 votes vote down vote up
@Override
public void initGui() {

    // Fill vars
    int guiBaseOffset = 35;
    guiBasePosition = width / 2 - guiBaseOffset;

    guiShowBasePosX = width / 2 - 35;
    guiShowBasePosY = height / 2 + 25;

    guiShowType = GuiType.ANVIL;
    guiShowState = 0;
    lastTime = Minecraft.getSystemTime();
    currentTime = Minecraft.getSystemTime();

    // Init Config
    initKeyValues();

    // Init buttons
    addStandardButtons();
    addCraftingButtons();
}
 
Example 2
Source File: AbstractAnimationHandler.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@InvokeEvent
public void onRender(RenderEvent e) {
    long systemTime = Minecraft.getSystemTime();
    animationStates.values().forEach(animationState -> animationState.update(systemTime));
    onRender();

    long systemTime1 = System.currentTimeMillis();
    if (this.systemTime == 0) this.systemTime = systemTime1;

    int msPerTick = 1000 / 120;
    if (this.systemTime < systemTime1 + msPerTick) {
        this.systemTime = systemTime1 + msPerTick;
        state = modifyState();

        if (state <= 0) {
            asc = true;
            right = !right;
            onStartOfState();
        } else if (state >= 100) {
            asc = false;
        }
    }
}
 
Example 3
Source File: FlossDanceHandler.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public float modifyState() {
    float speed = 6;
    if (systemTime == 0) systemTime = Minecraft.getSystemTime();

    while (systemTime < Minecraft.getSystemTime() + (1000 / 120)) {
        state = HyperiumGui.clamp(state + (asc ? speed : -speed), 0.0f, 100.0f);
        systemTime += (1000 / 120);

        if (state <= 0) {
            asc = true;
            right = !right;
            armsDirection = ArmsDirection.values()[armsDirection.ordinal() + 1 >= ArmsDirection.values().length ? 0 : armsDirection.ordinal() + 1];
            fillRandomHeadMovementArray();
        } else if (state >= 100) {
            asc = false;
        }
    }

    return state;
}
 
Example 4
Source File: GuiControls.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Fired when a key is typed (except F11 who toggle full screen). This is
 * the equivalent of KeyListener.keyTyped(KeyEvent e). Args : character
 * (character on the key), keyCode (lwjgl Keyboard key code)
 */
@Override
protected void keyTyped(char typedChar, int keyCode) {
    if (this.currentKeyBinding != null) {
        if (keyCode == 1) {
            setKeyBinding(this.currentKeyBinding, 0);
        } else {
            setKeyBinding(this.currentKeyBinding, keyCode);
        }

        this.currentKeyBinding = null;
        this.time = Minecraft.getSystemTime();
    } else {
        super.keyTyped(typedChar, keyCode);
        if (keyCode == 1) {
            mc.displayGuiScreen(parentScreen);
        }
    }
}
 
Example 5
Source File: GuiControls.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Fired when a key is typed (except F11 who toggle full screen). This is
 * the equivalent of KeyListener.keyTyped(KeyEvent e). Args : character
 * (character on the key), keyCode (lwjgl Keyboard key code)
 */
@Override
protected void keyTyped(char typedChar, int keyCode) {
    if (this.currentKeyBinding != null) {
        if (keyCode == 1) {
            setKeyBinding(this.currentKeyBinding, 0);
        } else {
            setKeyBinding(this.currentKeyBinding, keyCode);
        }

        this.currentKeyBinding = null;
        this.time = Minecraft.getSystemTime();
    } else {
        super.keyTyped(typedChar, keyCode);
        if (keyCode == 1) {
            mc.displayGuiScreen(parentScreen);
        }
    }
}
 
Example 6
Source File: GuiContainerScreen.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void updateScreen() {
	int mouseX = Mouse.getX() * width / mc.displayWidth;
	int mouseY = height - Mouse.getY() * height / mc.displayHeight - 1;
	
	// Handle onMouseMove.
	if ((mouseX != _lastMouseX) || (mouseY != _lastMouseY)) {
		GuiElementBase pressed = context.getPressed();
		if (pressed != null) {
			ElementInfo info = ElementInfo.getElementHierarchy(pressed).getFirst();
			pressed.onMouseMove(mouseX - info.globalX, mouseY - info.globalY);
		} else if (container.contains(mouseX, mouseY))
			container.onMouseMove(mouseX, mouseY);
		_lastMouseX = mouseX;
		_lastMouseY = mouseY;
	}
	
	// Handle tooltips.
	GuiElementBase tooltipElement = new ElementInfo(container)
		.getElementsAt(mouseX, mouseY)
		.map(info -> info.element)
		.filter(element -> element.hasTooltip())
		.reduce((first, second) -> second) // Get the last element.
		.orElse(null);
	if (tooltipElement != _tooltipElement)
		_tooltipTime = Minecraft.getSystemTime();
	_tooltipElement = tooltipElement;
}
 
Example 7
Source File: EntryValueEffectOpacity.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderEffect(int x, int y, int width, int height, float opacity) {
	if (opacity <= 0) return;
	Minecraft mc = Minecraft.getMinecraft();
	float animProgress = Minecraft.getSystemTime() / 400.0F;
	
	int color = 0xFF8040CC;
	float r = (color >> 16 & 0xFF) / 255.0F;
	float g = (color >> 8 & 0xFF) / 255.0F;
	float b = (color & 0xFF) / 255.0F;
	GlStateManager.color(r, g, b, opacity * 0.6F);
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
	GlStateManager.enableAlpha();
	GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0.0F);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		GuiUtils.drawTexturedModalRect(x, y, 0, 0, width, height, 0);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
	GlStateManager.disableAlpha();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
}
 
Example 8
Source File: SexyFontRenderer.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public int drawString(String text, float x, float y, int color, boolean dropShadow) {
	if(!(SexyFont.sexyTime || SexyFont.alwaysSexyTime)) {
		return super.drawString(text, x, y, color, dropShadow);
	}
	
	if(SexyFont.intermittentSexyTime) {
		int hash = text.hashCode() % 8;
		int offset = (int) (Minecraft.getSystemTime() / 230f) % 8;
		if((hash + offset) % 8 != 0) {
			return super.drawString(text, x, y, color, dropShadow);
		}
	}
	
	//Ok this is epic
	float posX = x;
	float huehuehue = (Minecraft.getSystemTime() / 700f) % 1;
	float huehuehueStep = rangeRemap((float) (Math.sin(Minecraft.getSystemTime() / 2000f) % 6.28318f), -1, 1, 0.01f, 0.15f);
	
	String textRender = ChatFormatting.stripFormatting(text);
	
	for(int i = 0; i < textRender.length(); i++) {
		int c = (color & 0xFF000000) | MathHelper.hsvToRGB(huehuehue, .8f, 1);
		
		float yOffset = (float) Math.sin(i + (Minecraft.getSystemTime() / 300f));
		
		posX = super.drawString(String.valueOf(textRender.charAt(i)), posX, y + yOffset, c, true) - 1;
		
		huehuehue += huehuehueStep;
		huehuehue %= 1;
	}
	
	return (int) posX;
}
 
Example 9
Source File: ModularUIGui.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderReturningItemStack() {
    if (!this.returningStack.isEmpty()) {
        float partialTicks = (float) (Minecraft.getSystemTime() - this.returningStackTime) / 100.0F;
        if (partialTicks >= 1.0F) {
            partialTicks = 1.0F;
            this.returningStack = ItemStack.EMPTY;
        }
        int deltaX = this.returningStackDestSlot.xPos - this.touchUpX;
        int deltaY = this.returningStackDestSlot.yPos - this.touchUpY;
        int currentX = this.touchUpX + (int) ((float) deltaX * partialTicks);
        int currentY = this.touchUpY + (int) ((float) deltaY * partialTicks);
        //noinspection ConstantConditions
        this.drawItemStack(this.returningStack, currentX, currentY, null);
    }
}
 
Example 10
Source File: GuiConfig.java    From CraftingKeys with MIT License 5 votes vote down vote up
private void drawInfo() {

        // Insert Gui by selected Type
        currentTime = Minecraft.getSystemTime();
        int waitingTimeMS = 3000;
        if (currentTime - lastTime > waitingTimeMS) {
            showNextGui();
            GL11.glColor4f(0.5F, 0.5F, 0.5F, 1F);
            lastTime = Minecraft.getSystemTime();
        }


        switch (guiShowType) {

            case FURNACE:
                genFurnaceInfo();
                break;
            case BREWINGSTAND:
                genBrewingStandInfo();
                break;
            case DISPENSER:
                genDispenserInfo();
                break;
            case ENCHANTMENT:
                genEnchantmentInfo();
                break;
            case INVENTORY:
                genInventoryInfo();
                break;
            case VILLAGER:
                genVillagerInfo();
                break;
            case ANVIL:
                genAnvilInfo();
                break;
        }
    }
 
Example 11
Source File: HyperiumRenderItem.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Basically the same as renderEffect, but does not include the depth code and uses custom color
 *
 * @param model the model
 */
private void renderPot(IBakedModel model, int color) {
    GlStateManager.depthMask(false);
    GlStateManager.disableLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_COLOR, 1);
    ((IMixinRenderItem) parent).getTextureManager().bindTexture(RES_ITEM_GLINT);
    GlStateManager.matrixMode(GL11.GL_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.scale(8.0F, 8.0F, 8.0F);
    float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
    GlStateManager.translate(f, 0.0F, 0.0F);
    GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
    ((IMixinRenderItem2) parent).callRenderModel(model, color);
    GlStateManager.popMatrix();
    GlStateManager.pushMatrix();
    GlStateManager.scale(8.0F, 8.0F, 8.0F);
    float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
    GlStateManager.translate(-f1, 0.0F, 0.0F);
    GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
    ((IMixinRenderItem2) parent).callRenderModel(model, color);
    GlStateManager.popMatrix();
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableLighting();
    GlStateManager.depthMask(true);

    ((IMixinRenderItem) parent).getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
}
 
Example 12
Source File: GuiContainerScreen.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	drawBackground(0);
	container.draw(mouseX, mouseY, partialTicks);
	
	if ((_tooltipElement != null) && (Minecraft.getSystemTime() >=
			_tooltipTime + _tooltipElement.getTooltipDelay()))
		_tooltipElement.drawTooltip(mouseX, mouseY, width, height, partialTicks);
	
	if (GuiContext.DEBUG)
		drawDebugInfo(mouseX, mouseY, partialTicks);
}
 
Example 13
Source File: ItemDropChecker.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Checks if the player has confirmed that they want to drop the given item stack.
 * The player confirms that they want to drop the item when they try to drop it the number of
 * times specified in {@code numberOfActions}
 *
 * @param item the item stack the player is attempting to drop
 * @param numberOfActions the number of times the player has to drop the item to confirm
 * @return {@code true} if the player has dropped the item enough
 */
public boolean dropConfirmed(ItemStack item, int numberOfActions) {
    logger.entry(item, numberOfActions);

    if (item == null) {
        logger.throwing(new NullPointerException("Item cannot be null!"));
    }
    else if (numberOfActions < 2) {
        logger.throwing(new IllegalArgumentException("At least two attempts are required."));
    }

    // If there's no drop confirmation active, set up a new one.
    if (itemOfLastDropAttempt == null) {
        itemOfLastDropAttempt = item;
        timeOfLastDropAttempt = Minecraft.getSystemTime();
        attemptsRequiredToConfirm = numberOfActions - 1;
        onDropConfirmationFail();
        return logger.exit(false);
    }
    else {
        long DROP_CONFIRMATION_TIMEOUT = 3000L;

        // Reset the current drop confirmation on time out or if the item being dropped changes.
        if (Minecraft.getSystemTime() - timeOfLastDropAttempt > DROP_CONFIRMATION_TIMEOUT ||
                !ItemStack.areItemStacksEqual(item, itemOfLastDropAttempt)) {
            resetDropConfirmation();
            return dropConfirmed(item, numberOfActions);
        }
        else {
            if (attemptsRequiredToConfirm >= 1) {
                onDropConfirmationFail();
                return logger.exit(false);
            }
            else {
                resetDropConfirmation();
                return logger.exit(true);
            }
        }
    }
}
 
Example 14
Source File: RenderUtils.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Reimplement vanilla item so we can draw pearl stacks with opacity support.
 */
private static void renderEffect(IBakedModel model) {
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(514);
	GlStateManager.disableLighting();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
	GlStateManager.matrixMode(5890);
	GlStateManager.pushMatrix();
	GlStateManager.scale(8.0F, 8.0F, 8.0F);
	float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
	GlStateManager.translate(f, 0.0F, 0.0F);
	GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
	renderModel(model, -8372020, ItemStack.EMPTY);
	GlStateManager.popMatrix();
	GlStateManager.pushMatrix();
	GlStateManager.scale(8.0F, 8.0F, 8.0F);
	float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
	GlStateManager.translate(-f1, 0.0F, 0.0F);
	GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
	renderModel(model, -8372020, ItemStack.EMPTY);
	GlStateManager.popMatrix();
	GlStateManager.matrixMode(5888);
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
	GlStateManager.enableLighting();
	GlStateManager.depthFunc(515);
	GlStateManager.depthMask(true);
	Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	GlStateManager.scale(1 / 8.0F, 1 / 8.0F, 1 / 8.0F);
}
 
Example 15
Source File: VillageLordGuiContainer.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void drawActionButton(String label, Action action, int mouseX, int mouseY, int xOffset) {
	GuiButton abandonButton = new GuiButton(0, guiLeft + 105 + xOffset, guiTop + 130, buttonWidth, buttonHeight, I18n.format(label));
	abandonButton.drawButton(mc, mouseX, mouseY, 1);
	if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1) {
		if (abandonButton.mousePressed(mc, mouseX, mouseY) && mouseCooldownOver()) {
			mousePressed = Minecraft.getSystemTime();
			MessageQuestUpdate message = new MessageQuestUpdate();
			message.action = action;
			message.lordEntityId = inventory.getEntityId();
			ToroQuestPacketHandler.INSTANCE.sendToServer(message);
		}
	}
}
 
Example 16
Source File: AbstractAnimationHandler.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public AnimationState() {
    systemTime = Minecraft.getSystemTime();
    toggled = false;
}
 
Example 17
Source File: ConfirmationPopup.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean render() {
    if (framesLeft <= 0) return true;

    if (text.equalsIgnoreCase("Party request from " + acceptFrom)) {
        callback.accept(true);
        return true;
    }

    while (systemTime < Minecraft.getSystemTime() + (1000 / 60)) {
        framesLeft--;
        systemTime += (1000 / 60);
    }

    percentComplete = HyperiumGui.clamp(
        HyperiumGui.easeOut(
            percentComplete,
            framesLeft < lowerThreshold ? 0.0f :
                framesLeft > upperThreshold ? 1.0f : framesLeft,
            0.01f,
            15f
        ),
        0.0f,
        1.0f
    );

    FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());

    int middle = sr.getScaledWidth() / 2;
    int halfWidth = 105;
    int currWidth = (int) (halfWidth * percentComplete);

    // Background
    Gui.drawRect(
        middle - currWidth,
        50,
        middle + currWidth,
        95,
        new Color(27, 27, 27).getRGB()
    );

    if (percentComplete == 1.0F) {
        long length = upperThreshold - lowerThreshold;
        long current = framesLeft - lowerThreshold;
        float progress = 1.0F - HyperiumGui.clamp((float) current / (float) length, 0.0F, 1.0F);

        // Progress
        Gui.drawRect(
            middle - currWidth,
            93,
            (int) (middle - currWidth + (210 * progress)),
            95,
            new Color(128, 226, 126).getRGB()
        );

        fr.drawString(text, sr.getScaledWidth() / 2 - fr.getStringWidth(text) / 2, 58, 0xFFFFFF);

        String s = ChatColor.GREEN + "[Y] Accept " + ChatColor.RED + "[N] Deny";
        fr.drawString(s, sr.getScaledWidth() / 2 - fr.getStringWidth(s) / 2, 70, -1);
    }

    return false;
}
 
Example 18
Source File: MixinLoadingScreenRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @author ConorTheDev
 * @reason Custom screen when loading to a new world
 */
@Inject(method = "setLoadingProgress", at = @At("HEAD"), cancellable = true)
private void setLoadingProgress(CallbackInfo ci) {
    if (Settings.HYPERIUM_LOADING_SCREEN) {
        long nanoTime = Minecraft.getSystemTime();

        if (nanoTime - systemTime >= 100L) {
            systemTime = nanoTime;
            ScaledResolution scaledresolution = new ScaledResolution(mc);
            int scaleFactor = scaledresolution.getScaleFactor();
            int scaledWidth = scaledresolution.getScaledWidth();
            int scaledHeight = scaledresolution.getScaledHeight();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferClear();
            } else {
                GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
            }

            framebuffer.bindFramebuffer(false);
            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D);
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            GlStateManager.loadIdentity();
            GlStateManager.translate(0.0F, 0.0F, -200.0F);

            if (!OpenGlHelper.isFramebufferEnabled()) GlStateManager.clear(16640);

            Tessellator tessellator = Tessellator.getInstance();
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
            mc.getTextureManager().bindTexture(new ResourceLocation("textures/world-loading.png"));

            Gui.drawModalRectWithCustomSizedTexture(0, 0, 0.0f, 0.0f, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight());

            int progress;
            if ("Loading world".equals(currentlyDisplayedText)) {
                if (message.isEmpty()) {
                    progress = 33;
                } else if (message.equals("Converting world")) {
                    progress = 66;
                } else if (message.equals("Building terrain")) {
                    progress = 90;
                } else {
                    progress = 100;
                }
            } else {
                progress = -1;
            }

            if (progress >= 0) {
                int maxProgress = 100;
                int barTop = 2;
                int barHeight = scaledResolution.getScaledHeight() - 15;
                GlStateManager.disableTexture2D();
                worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex();
                worldrenderer.pos(maxProgress + progress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex();
                tessellator.draw();
                GlStateManager.enableAlpha();
                GlStateManager.enableBlend();
                Gui.drawRect(0, scaledResolution.getScaledHeight() - 35, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
                    new Color(0, 0, 0, 50).getRGB());
                GlStateManager.disableAlpha();
                GlStateManager.disableBlend();
                GlStateManager.enableTexture2D();
            }

            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
            mc.fontRendererObj.drawString(currentlyDisplayedText, 5, scaledResolution.getScaledHeight() - 30, -1);
            mc.fontRendererObj.drawString(message, 5, scaledResolution.getScaledHeight() - 15, -1);
            framebuffer.unbindFramebuffer();

            if (OpenGlHelper.isFramebufferEnabled()) {
                framebuffer.framebufferRender(scaledWidth * scaleFactor, scaledHeight * scaleFactor);
            }

            mc.updateDisplay();

            try {
                Thread.yield();
            } catch (Exception ignored) {
            }
        }

        ci.cancel();
    }
}
 
Example 19
Source File: GuiContainer.java    From NotEnoughItems with MIT License 4 votes vote down vote up
/**
 * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
 */
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {

    if (manager.mouseClicked(mouseX, mouseY, mouseButton)) {
        return;
    }

    super.mouseClicked(mouseX, mouseY, mouseButton);
    boolean flag = this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100);
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    long i = Minecraft.getSystemTime();
    this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == mouseButton;
    this.ignoreMouseUp = false;

    if (mouseButton == 0 || mouseButton == 1 || flag) {
        int j = this.guiLeft;
        int k = this.guiTop;
        boolean flag1 = mouseX < j || mouseY < k || mouseX >= j + this.xSize || mouseY >= k + this.ySize;
        if (slot != null) {
            flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
        }
        int l = -1;

        if (slot != null) {
            l = slot.slotNumber;
        }

        if (flag1) {
            l = -999;
        }

        if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) {
            this.mc.displayGuiScreen(null);
            return;
        }

        if (l != -1) {
            if (this.mc.gameSettings.touchscreen) {
                if (slot != null && slot.getHasStack()) {
                    this.clickedSlot = slot;
                    this.draggedStack = null;
                    this.isRightMouseClick = mouseButton == 1;
                } else {
                    this.clickedSlot = null;
                }
            } else if (!this.dragSplitting) {
                if (this.mc.thePlayer.inventory.getItemStack() == null) {
                    if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100)) {
                        managerHandleMouseClick(slot, l, mouseButton, ClickType.CLONE);
                    } else {
                        boolean flag2 = l != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
                        ClickType clicktype = ClickType.PICKUP;

                        if (flag2) {
                            this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack() : null;
                            clicktype = ClickType.QUICK_MOVE;
                        } else if (l == -999) {
                            clicktype = ClickType.THROW;
                        }

                        managerHandleMouseClick(slot, l, mouseButton, clicktype);
                    }

                    this.ignoreMouseUp = true;
                } else {
                    this.dragSplitting = true;
                    this.dragSplittingButton = mouseButton;
                    this.dragSplittingSlots.clear();

                    if (mouseButton == 0) {
                        this.dragSplittingLimit = 0;
                    } else if (mouseButton == 1) {
                        this.dragSplittingLimit = 1;
                    } else if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100)) {
                        this.dragSplittingLimit = 2;
                    }
                }
            }
        }
    }

    this.lastClickSlot = slot;
    this.lastClickTime = i;
    this.lastClickButton = mouseButton;
}
 
Example 20
Source File: RotorSpecialRenderer.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y,
		double z, float f) {
	TileEntityTurbineRotorBearing bearing = (TileEntityTurbineRotorBearing)tileentity;
	
	if(bearing == null || !bearing.isConnected()) { return; }
	
	MultiblockTurbine turbine = bearing.getTurbine();
	
	if(!turbine.isAssembled() || !turbine.getActive() || !turbine.hasGlass()) { return; }
	
	Integer displayList = bearing.getDisplayList();
	ForgeDirection rotorDir = bearing.getOutwardsDir().getOpposite();
	
	if(displayList == null) {
		RotorInfo info = bearing.getRotorInfo();
		displayList = generateRotor(info);
		bearing.setDisplayList(displayList);
	}
	
	float angle = bearing.getAngle();
	long elapsedTime = Minecraft.getSystemTime() - ClientProxy.lastRenderTime;
	
	float speed = turbine.getRotorSpeed();
	if(speed > 0.001f) {
		angle += speed * ((float)elapsedTime / 60000f) * 360f; // RPM * time in minutes * 360 degrees per rotation
		angle = angle % 360f;
		bearing.setAngle(angle);
	}

	GL11.glPushMatrix();
	GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_LIGHTING);

	bindTexture(net.minecraft.client.renderer.texture.TextureMap.locationBlocksTexture);

	GL11.glTranslated(x + rotorDir.offsetX, y + rotorDir.offsetY, z + rotorDir.offsetZ);
	if(rotorDir.offsetX != 0) {
		GL11.glTranslated(0, 0.5, 0.5);
	}
	else if(rotorDir.offsetY != 0) {
		GL11.glTranslated(0.5, 0, 0.5);
	}
	else if(rotorDir.offsetZ != 0) {
		GL11.glTranslated(0.5, 0.5, 0);
	}

	GL11.glRotatef(angle, rotorDir.offsetX, rotorDir.offsetY, rotorDir.offsetZ);
	GL11.glColor3f(1f, 1f, 1f);
	GL11.glCallList(displayList);

	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glPopAttrib();
	GL11.glPopMatrix();
}