Search in sources :

Example 96 with Minecraft

use of net.minecraft.client.Minecraft in project MorePlanets by SteveKunG.

the class ClientRendererUtil method renderModel.

public static void renderModel(IBlockState state) {
    Minecraft mc = Minecraft.getMinecraft();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
    int i = mc.getBlockColors().colorMultiplier(state, (IBlockAccess) null, (BlockPos) null, 0);
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
    if (EntityRenderer.anaglyphEnable) {
        i = TextureUtil.anaglyphColor(i);
    }
    float f = (i >> 16 & 255) / 255.0F;
    float f1 = (i >> 8 & 255) / 255.0F;
    float f2 = (i & 255) / 255.0F;
    ClientRendererUtil.renderModelBrightnessColor(state, model, 1.0F, f, f1, f2);
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft)

Example 97 with Minecraft

use of net.minecraft.client.Minecraft in project Almura by AlmuraDev.

the class MixinGuiIngame method renderPotionEffects.

/**
 * @author Grinch - Steven Downer
 * @reason Move down where PotionEffects render to not conflict with the far right element of the OriginHUD
 */
@Overwrite
protected void renderPotionEffects(ScaledResolution resolution) {
    Minecraft mc = Minecraft.getMinecraft();
    Collection<PotionEffect> collection = mc.player.getActivePotionEffects();
    if (!collection.isEmpty()) {
        mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
        GlStateManager.enableBlend();
        int i = 0;
        int j = 0;
        for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection)) {
            Potion potion = potioneffect.getPotion();
            if (!potion.shouldRenderHUD(potioneffect))
                continue;
            // Rebind in case previous renderHUDEffect changed texture
            mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
            if (potioneffect.doesShowParticles()) {
                int k = resolution.getScaledWidth();
                // TODO Figure out how to do this without overwrite
                // Almura start
                int l = hud.getHUD().map(AbstractHUD::getPotionOffsetY).orElse(1);
                if (mc.isDemo()) {
                    l += 15;
                }
                int i1 = potion.getStatusIconIndex();
                if (potion.isBeneficial()) {
                    ++i;
                    k = k - 25 * i;
                } else {
                    ++j;
                    k = k - 25 * j;
                    l += 26;
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                float f = 1.0F;
                if (potioneffect.getIsAmbient()) {
                    this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
                } else {
                    this.drawTexturedModalRect(k, l, 141, 166, 24, 24);
                    if (potioneffect.getDuration() <= 200) {
                        int j1 = 10 - potioneffect.getDuration() / 20;
                        f = MathHelper.clamp((float) potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float) potioneffect.getDuration() * (float) Math.PI / 5.0F) * MathHelper.clamp((float) j1 / 10.0F * 0.25F, 0.0F, 0.25F);
                    }
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, f);
                // FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
                if (potion.hasStatusIcon())
                    this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
                potion.renderHUDEffect(k, l, potioneffect, mc, f);
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) Minecraft(net.minecraft.client.Minecraft) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 98 with Minecraft

use of net.minecraft.client.Minecraft in project Almura by AlmuraDev.

the class ClientboundPageListingsPacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundPageListingsPacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            this.manager.setPageEntries(message.pageEntries, message.switchToPageId);
            SimplePageView view = null;
            final GuiScreen currentScreen = client.currentScreen;
            if (currentScreen instanceof UIMessageBox.MessageBoxDialogScreen && ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent() instanceof SimplePageView) {
                view = (SimplePageView) ((UIMessageBox.MessageBoxDialogScreen) currentScreen).getParent();
            } else if (currentScreen instanceof SimplePageView) {
                view = (SimplePageView) currentScreen;
            }
            if (view != null) {
                view.refreshPageEntries(message.switchToPageId);
            }
        }
    }
}
Also used : UIMessageBox(com.almuradev.almura.shared.client.ui.component.dialog.UIMessageBox) GuiScreen(net.minecraft.client.gui.GuiScreen) Minecraft(net.minecraft.client.Minecraft) SimplePageView(com.almuradev.almura.feature.guide.client.gui.SimplePageView)

Example 99 with Minecraft

use of net.minecraft.client.Minecraft in project Almura by AlmuraDev.

the class ClientboundNucleusNameChangeMappingPacketHandler method handleMessage.

@Override
public void handleMessage(final ClientboundNucleusNameChangeMappingPacket message, final RemoteConnection connection, final Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final UUID entityUniqueId = message.uuid;
            final Text nickname = message.text;
            this.nickManager.put(entityUniqueId, nickname);
            final World world = client.world;
            if (world != null) {
                final EntityPlayer player = world.getPlayerEntityByUUID(entityUniqueId);
                if (player != null) {
                    final String newNick = ForgeEventFactory.getPlayerDisplayName(player, TextSerializers.LEGACY_FORMATTING_CODE.serialize(nickname));
                    this.nickManager.put(entityUniqueId, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(newNick));
                    try {
                        this.nickManager.adjustPlayerNickname(player, newNick);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
            // queue an update of the tab list display names (Vanilla may change the displayname in the PlayerListPacket)
            client.addScheduledTask(() -> {
                final EntityPlayerSP player = client.player;
                if (player != null && player.connection != null) {
                    final NetworkPlayerInfo info = player.connection.getPlayerInfo(entityUniqueId);
                    if (info != null) {
                        info.setDisplayName(SpongeTexts.toComponent(nickname));
                    }
                }
            });
        }
    }
}
Also used : NetworkPlayerInfo(net.minecraft.client.network.NetworkPlayerInfo) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Text(org.spongepowered.api.text.Text) UUID(java.util.UUID) World(net.minecraft.world.World) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft)

Example 100 with Minecraft

use of net.minecraft.client.Minecraft in project Almura by AlmuraDev.

the class ClientboundNucleusNameMappingsPacketHandler method handleMessage.

@Override
public void handleMessage(final ClientboundNucleusNameMappingsPacket message, final RemoteConnection connection, final Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final Map<UUID, Text> nicknames = message.nicknames;
            this.nickManager.putAll(nicknames);
            final World world = client.world;
            if (world != null) {
                message.nicknames.forEach((uniqueId, nickname) -> {
                    final EntityPlayer player = world.getPlayerEntityByUUID(uniqueId);
                    if (player != null) {
                        final String newNick = ForgeEventFactory.getPlayerDisplayName(player, TextSerializers.LEGACY_FORMATTING_CODE.serialize(nickname));
                        this.nickManager.put(player.getUniqueID(), TextSerializers.LEGACY_FORMATTING_CODE.deserialize(newNick));
                        try {
                            this.nickManager.adjustPlayerNickname(player, newNick);
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
            client.addScheduledTask(() -> {
                final EntityPlayerSP player = client.player;
                if (player != null && player.connection != null) {
                    message.nicknames.forEach((uniqueId, nickname) -> {
                        final NetworkPlayerInfo info = player.connection.getPlayerInfo(uniqueId);
                        if (info != null) {
                            info.setDisplayName(SpongeTexts.toComponent(nickname));
                        }
                    });
                }
            });
        }
    }
}
Also used : NetworkPlayerInfo(net.minecraft.client.network.NetworkPlayerInfo) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Text(org.spongepowered.api.text.Text) UUID(java.util.UUID) World(net.minecraft.world.World) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft)

Aggregations

Minecraft (net.minecraft.client.Minecraft)100 ItemStack (net.minecraft.item.ItemStack)17 ScaledResolution (net.minecraft.client.gui.ScaledResolution)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 ArrayList (java.util.ArrayList)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 FontRenderer (net.minecraft.client.gui.FontRenderer)6 WorldClient (net.minecraft.client.multiplayer.WorldClient)6 World (net.minecraft.world.World)6 Tessellator (net.minecraft.client.renderer.Tessellator)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 Block (net.minecraft.block.Block)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 SimplePageView (com.almuradev.almura.feature.guide.client.gui.SimplePageView)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)3 GuiScreen (net.minecraft.client.gui.GuiScreen)3