Java Code Examples for net.minecraftforge.fml.client.FMLClientHandler

The following examples show how to use net.minecraftforge.fml.client.FMLClientHandler. These examples are extracted from open source projects. 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
/**
 * Get resource location from url
 *
 * @param url - url to get the file from
 * @return ResourceLocation
 */
public static ResourceLocation getTexture(URL url) {
    init();
    if (!URL_TEXTURES.containsKey(url)) {
        URL_TEXTURES.put(url, new WrappedResource(null));
        queueImage(url);
    }

    WrappedResource wr = URL_TEXTURES.get(url);
    if (wr.location == null) {
        if (URL_IMAGES.get(url) != null && URL_IMAGES.get(url).image != null) {
            DynamicTexture texture = new DynamicTexture(URL_IMAGES.get(url).image);
            WrappedResource wr2 = new WrappedResource(FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation(url.toString(), texture));
            URL_TEXTURES.put(url, wr2);
            return wr2.location;
        } else {
            return FULLY_TRANSPARENT_TEXTURE;
        }
    }

    return wr.location;
}
 
Example 2
Source Project: Cyberware   Source File: EssentialsMissingHandlerClient.java    License: MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleRenderHand(RenderHandEvent event)
{
	if (CyberwareConfig.RENDER && !(FMLClientHandler.instance().hasOptifine()) && (missingArm || missingSecondArm || hasRoboLeft || hasRoboRight))
	{
		float partialTicks = event.getPartialTicks();
		EntityRenderer er = mc.entityRenderer;
		event.setCanceled(true);
		
		
		boolean flag = mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)mc.getRenderViewEntity()).isPlayerSleeping();

		if (mc.gameSettings.thirdPersonView == 0 && !flag && !mc.gameSettings.hideGUI && !mc.playerController.isSpectator())
		{
			er.enableLightmap();
			renderItemInFirstPerson(partialTicks);
			er.disableLightmap();
		}
	}
}
 
Example 3
Source Project: Signals   Source File: GlassesHUD.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void render2D(){
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    EntityPlayer player = minecraft.player;
    ItemStack helmetStack = player.inventory.armorInventory.get(3);
    if(!helmetStack.isEmpty() && minecraft.inGameHasFocus && helmetStack.getItem() == Items.DIAMOND_HELMET) {
        GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPushMatrix();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glColor4d(0, 1, 0, 0.8D);

        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        for(int i = 0; i < messages.size(); i++) {
            minecraft.fontRenderer.drawString(messages.get(i).localizedMessage, 16, 16 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0xFF0000);
        }
    }
}
 
Example 4
@Override
protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) throws Exception {
	INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();

	switch (FMLCommonHandler.instance().getEffectiveSide()) {
		case CLIENT:
			FMLClientHandler.instance().getClient().addScheduledTask(() -> packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer()));
			break;
		case SERVER:
			FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> packet.handleServerSide(((NetHandlerPlayServer) netHandler).player));
			break;
		default:
			break;
	}

}
 
Example 5
Source Project: NOVA-Core   Source File: ClientProxy.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
	//Backward entity particle unwrapper
	if (entity instanceof BWParticle) {
		Particle particle = ((BWParticle) entity).createParticle(world);
		Vector3D position = entity.position();
		particle.posX = position.getX();
		particle.posY = position.getY();
		particle.posZ = position.getZ();
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle);
		return Game.natives().toNova(particle);
	} else {
		FWParticle bwEntityFX = new FWParticle(world, entity);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
		return bwEntityFX.wrapped;
	}
}
 
Example 6
Source Project: NOVA-Core   Source File: FWParticle.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderParticle(VertexBuffer worldRendererIn, net.minecraft.entity.Entity p_180434_2_, float p_70539_2_, float x, float y, float z, float p_70539_6_, float p_70539_7_) {
	if (firstTick) {
		prevPosX = posX;
		prevPosY = posY;
		prevPosZ = posZ;
		setPosition(posX, posY, posZ);
		firstTick = false;
	}
	float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX);
	float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY);
	float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ);

	Tessellator.getInstance().draw();
	FWEntityRenderer.render(this, wrapped, f11, f12, f13);
	Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK);
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderUtility.particleResource);
}
 
Example 7
@Override
protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) throws Exception {
	INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();

	switch (FMLCommonHandler.instance().getEffectiveSide()) {
		case CLIENT:
			FMLClientHandler.instance().getClient().addScheduledTask(() -> packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer()));
			break;
		case SERVER:
			FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> packet.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity));
			break;
		default:
			break;
	}

}
 
Example 8
Source Project: NOVA-Core   Source File: ClientProxy.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
	//Backward entity particle unwrapper
	if (entity instanceof BWEntityFX) {
		EntityFX entityFX = ((BWEntityFX) entity).createEntityFX(world);
		Vector3D position = entity.position();
		entityFX.posX = position.getX();
		entityFX.posY = position.getY();
		entityFX.posZ = position.getZ();
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
		return EntityConverter.instance().toNova(entityFX);
	} else {
		FWEntityFX bwEntityFX = new FWEntityFX(world, entity);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
		return bwEntityFX.wrapped;
	}
}
 
Example 9
Source Project: NOVA-Core   Source File: FWEntityFX.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderParticle(WorldRenderer worldRendererIn, net.minecraft.entity.Entity p_180434_2_, float p_70539_2_, float x, float y, float z, float p_70539_6_, float p_70539_7_) {
	if (firstTick) {
		prevPosX = posX;
		prevPosY = posY;
		prevPosZ = posZ;
		prevRotationYaw = rotationYaw;
		prevRotationPitch = rotationPitch;
		setPosition(posX, posY, posZ);
		firstTick = false;
	}
	float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX);
	float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY);
	float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ);

	Tessellator.getInstance().draw();
	FWEntityRenderer.render(this, wrapped, f11, f12, f13);
	Tessellator.getInstance().getWorldRenderer().startDrawingQuads();
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderUtility.particleResource);
}
 
Example 10
Source Project: Custom-Main-Menu   Source File: ActionOpenModConfig.java    License: MIT License 6 votes vote down vote up
@Override
public void perform(Object source, GuiCustom parent)
{
	for (ModContainer mod : Loader.instance().getModList())
	{
		if (mod.getModId().equals(modid))
		{
			IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(mod);

			if (guiFactory != null)
			{
				GuiScreen newScreen = guiFactory.createConfigGui(parent);
				Minecraft.getMinecraft().displayGuiScreen(newScreen);
			}
		}
	}
}
 
Example 11
@SubscribeEvent
public void onGuiOpenEvent(GuiOpenEvent event)
{
    // Reset the scrolling modifier when the player opens a GUI.
    // Otherwise the key up event will get eaten and our scrolling mode will get stuck on
    // until the player sneaks again.
    // FIXME Apparently there are key input events for GUI screens in 1.8,
    // so this probably can be removed then.
    InputEventHandler.resetModifiers();

    // Opening the player's Inventory GUI
    if (event.getGui() != null && event.getGui().getClass() == GuiInventory.class)
    {
        EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity();

        if (this.handyBagShouldOpen && player != null && ItemHandyBag.getOpenableBag(player).isEmpty() == false)
        {
            if (event.isCancelable())
            {
                event.setCanceled(true);
            }

            PacketHandler.INSTANCE.sendToServer(new MessageOpenGui(player.dimension, ReferenceGuiIds.GUI_ID_HANDY_BAG));
        }
    }
}
 
Example 12
Source Project: IGW-mod   Source File: TickHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static String getCurrentObjectName(){
    if(lastEntityHovered != null) {
        return lastEntityHovered.getName();
    } else {
        try {
            World world = FMLClientHandler.instance().getClient().world;
            IBlockState blockState = world.getBlockState(coordHovered);
            if(blockState != null) {
                ItemStack idPicked = blockState.getBlock().getPickBlock(blockState, FMLClientHandler.instance().getClient().objectMouseOver, world, coordHovered, FMLClientHandler.instance().getClientPlayerEntity());
                return (!idPicked.isEmpty() ? idPicked : new ItemStack(blockState.getBlock(), 1, blockState.getBlock().getMetaFromState(blockState))).getDisplayName(); //TODO test blockState.getBlock().getDamage()
            }
        } catch(Throwable e) {}
        return TextFormatting.RED + "<ERROR>";
    }

}
 
Example 13
Source Project: MediaMod   Source File: SpotifyHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void refreshSpotify() {
    if (spotifyApi.getRefreshToken() != null) {
        if (FMLClientHandler.instance().getClient().thePlayer != null) {
            PlayerMessager.sendMessage("&8INFO: &9Attempting to refresh access token...");
        } else {
            MediaMod.INSTANCE.LOGGER.info("Attempting to refresh access token...");
        }

        try {
            RefreshResponse refreshResponse = WebRequest.requestToMediaModAPI(WebRequestType.GET, "spotify/refreshToken?token=" + spotifyApi.getRefreshToken(), RefreshResponse.class);

            if (refreshResponse == null) {
                MediaMod.INSTANCE.LOGGER.error("Error: tokenAPIResponse is null");
                PlayerMessager.sendMessage("&8&lDEBUG: &rFailed to login to Spotify!");
                return;
            }

            spotifyApi = new SpotifyAPI(refreshResponse.accessToken, spotifyApi.getRefreshToken());

            if (spotifyApi.getRefreshToken() != null) {
                logged = true;
                Settings.REFRESH_TOKEN = spotifyApi.getRefreshToken();
                Settings.saveConfig();
                PlayerMessager.sendMessage("&a&lSUCCESS! &rLogged into Spotify!");

                CurrentlyPlayingObject currentTrack = spotifyApi.getCurrentTrack();

                if (MediaMod.INSTANCE.DEVELOPMENT_ENVIRONMENT && currentTrack != null) {
                    PlayerMessager.sendMessage("&8&lDEBUG: &rCurrent Song: " + currentTrack.item.name + " by " + currentTrack.item.album.artists[0].name);
                }
            }
        } catch (Exception e) {
            logged = false;
            MediaMod.INSTANCE.LOGGER.error("Error: " + e.getMessage());
            PlayerMessager.sendMessage("&8&lDEBUG: &rFailed to login to Spotify!");
        }
    }
}
 
Example 14
/**
 * Initialize key components
 */
private static void init() {
    if (!INITIALIZED) {
        try {
            GLContext.getCapabilities();
        } catch (RuntimeException ignored) {
            return;
        }
        FULLY_TRANSPARENT_TEXTURE = FMLClientHandler.instance().getClient().getTextureManager().getDynamicTextureLocation(
                "mediamod", new DynamicTexture(FULLY_TRANSPARENT_IMAGE));
        INITIALIZED = true;
    }
}
 
Example 15
Source Project: TofuCraftReload   Source File: GuiDownloadTofuTerrain.java    License: MIT License 5 votes vote down vote up
public GuiDownloadTofuTerrain() {
    super();
    this.mc = FMLClientHandler.instance().getClient();
    this.viewportTexture = new DynamicTexture(256, 256);
    this.panoramaBackground = mc.getTextureManager().getDynamicTextureLocation("background", viewportTexture);
    this.prevTime = Minecraft.getSystemTime();
}
 
Example 16
Source Project: Sakura_mod   Source File: ParticleSakuraLeaf.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 17
Source Project: Sakura_mod   Source File: ParticleMapleYellowLeaf.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 18
Source Project: Sakura_mod   Source File: ParticleMapleGreenLeaf.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 19
Source Project: Sakura_mod   Source File: ParticleSyrupDrop.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 20
Source Project: Sakura_mod   Source File: ParticleMapleOrangeLeaf.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 21
Source Project: Sakura_mod   Source File: ParticleMapleRedLeaf.java    License: MIT License 5 votes vote down vote up
@Override
public void renderParticle(BufferBuilder buffer, Entity entity, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
    // EffectRenderer will by default bind the vanilla particles texture, override with our own
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(ClientProxy.leafTexture);

    GlStateManager.depthMask(false);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);

    super.renderParticle(buffer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);

    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
}
 
Example 22
private static void setModResourcePack(String modid, AbstractResourcePack newPack) {
    FMLClientHandler clientHandler = FMLClientHandler.instance();
    IResourcePack oldPack = clientHandler.getResourcePackFor(modid);
    Map<String, IResourcePack> resourcePackMap = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
    resourcePackMap.put(modid, newPack);
    List<IResourcePack> resourcePackList = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
    resourcePackList.remove(oldPack);
    resourcePackList.add(newPack);
}
 
Example 23
@SideOnly(Side.CLIENT)
@Nullable
private static World getWorldClient(final int dimension) {
  final World world = FMLClientHandler.instance().getClient().world;
  if (world == null) {
    return null;
  }
  if (world.provider.getDimension() != dimension) {
    return null;
  }
  return world;
}
 
Example 24
Source Project: Wizardry   Source File: CapeHandler.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
	if (event.side == Side.CLIENT && event.phase == TickEvent.Phase.END) {
		World world = FMLClientHandler.instance().getWorldClient();
		if (world != null) {
			for (EntityPlayer player : world.playerEntities) {
				getCape(player).update(player);
			}
		}
	}
}
 
Example 25
Source Project: Signals   Source File: GlassesHUD.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void renderTick(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        if(mc != null && mc.player != null) {
            render2D();
        }
    }
}
 
Example 26
public File getBaseDirectory() {
	if (FMLCommonHandler.instance().getSide().isClient()) {
		FMLClientHandler.instance().getClient();
		return FMLClientHandler.instance().getClient().mcDataDir;
	} else {
		return new File(".");
	}
}
 
Example 27
Source Project: NOVA-Core   Source File: ClientProxy.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isPaused() {
	if (FMLClientHandler.instance().getClient().isSingleplayer() &&
		Optional.ofNullable(FMLClientHandler.instance().getClient().getIntegratedServer()).map(is -> !is.getPublic()).orElse(true)) {
		GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
		if (screen != null) {
			if (screen.doesGuiPauseGame()) {
				return true;
			}
		}
	}
	return false;
}
 
Example 28
Source Project: NOVA-Core   Source File: ClientProxy.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Entity spawnParticle(net.minecraft.world.World world, EntityFactory factory) {
	//Backward entity particle unwrapper
	Entity build = factory.build();
	if (build instanceof BWParticle) {
		Particle particle = ((BWParticle) build).createParticle(world);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle);
		return Game.natives().toNova(particle);
	} else {
		FWParticle bwEntityFX = new FWParticle(world, factory);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
		return bwEntityFX.wrapped;
	}
}
 
Example 29
public File getBaseDirectory() {
	if (FMLCommonHandler.instance().getSide().isClient()) {
		FMLClientHandler.instance().getClient();
		return FMLClientHandler.instance().getClient().mcDataDir;
	} else {
		return new File(".");
	}
}
 
Example 30
Source Project: NOVA-Core   Source File: ClientProxy.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isPaused() {
	if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) {
		GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen;
		if (screen != null) {
			if (screen.doesGuiPauseGame()) {
				return true;
			}
		}
	}
	return false;
}