Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
private static final int MAX_TIMER = 40;
private static int timer;
private static ItemStack stack;
@SubscribeEvent
public void lalala(RenderGameOverlayEvent.Pre event)
{
if (event.type == ElementType.HOTBAR) {
if (stack != mc.thePlayer.getCurrentEquippedItem()) {
stack = mc.thePlayer.getCurrentEquippedItem();
timer = MAX_TIMER;
}
if (timer > 0) {
--timer;
}
else {
event.setCanceled(true);
}
}
}
Attempted to cancel a uncancelable event
if (this.remainingHighlightTicks > 0 && this.highlightingItemStack != null)
{
String name = this.highlightingItemStack.getDisplayName();
int opacity = (int)((float)this.remainingHighlightTicks * 256.0F / 10.0F);
if (opacity > 255) opacity = 255;
if (opacity > 0)
{
int y = height - 59;
if (!mc.playerController.shouldDrawHUD()) y += 14;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
FontRenderer font = highlightingItemStack.getItem().getFontRenderer(highlightingItemStack);
if (font != null)
{
int x = (width - font.getStringWidth(name)) / 2;
font.drawStringWithShadow(name, x, y, WHITE | (opacity << 24));
}
else
{
int x = (width - fontrenderer.getStringWidth(name)) / 2;
fontrenderer.drawStringWithShadow(name, x, y, WHITE | (opacity << 24));
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
public void vanishingHotbar(RenderGameOverlayEvent event) {
if (event instanceof RenderGameOverlayEvent.Pre && event.type == ElementType.HOTBAR) {
if (!mc.thePlayer.capabilities.isCreativeMode) {
if (itemStack != mc.thePlayer.getCurrentEquippedItem()) {
itemStack = mc.thePlayer.getCurrentEquippedItem();
timer = MAX_TIMER;
}
if (timer > 0) {
--timer;
} else {
event.setCanceled(true);
}
}
}
}