mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Fancy flowers for contributors.
This commit is contained in:
1 parent
cae10236d3
commit
bb4785eb88
5 files changed
+176
-49
No files matched your search
@@ -65,8 +65,8 @@ public final class BaubleRenderHandler {
|
||||
ItemStack helm = player.inventory.armorItemInSlot(3);
|
||||
if(helm != null && helm.getItem() instanceof ItemTerrasteelHelm)
|
||||
ItemTerrasteelHelm.renderOnPlayer(helm, event);
|
||||
if(event.entityPlayer.getCommandSenderName().equals("Vazkii"))
|
||||
renderFancyExclusiveDevStuffBecauseImAnEvilDevWhoDoesntCareAboutTheCommunityBooo(event);
|
||||
|
||||
ContributorFancinessHandler.render(event);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -139,50 +139,5 @@ public final class BaubleRenderHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFancyExclusiveDevStuffBecauseImAnEvilDevWhoDoesntCareAboutTheCommunityBooo(RenderPlayerEvent event) {
|
||||
GL11.glPushMatrix();
|
||||
IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon;
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
Helper.translateToHeadLevel(event.entityPlayer);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
float t = 0.13F;
|
||||
GL11.glTranslatef(t, -0.5F, -0.1F);
|
||||
if(event.entityPlayer.motionY < 0)
|
||||
GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F);
|
||||
|
||||
float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F;
|
||||
GL11.glRotatef(r, 0F, 0F, 1F);
|
||||
float s = 0.9F;
|
||||
GL11.glScalef(s, s, s);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glRotatef(-r, 0F, 0F, 1F);
|
||||
GL11.glTranslatef(-t, -0F, 0F);
|
||||
GL11.glScalef(-1F, 1F, 1F);
|
||||
GL11.glTranslatef(t, -0F, 0F);
|
||||
GL11.glRotatef(r, 0F, 0F, 1F);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
icon = BlockModFlower.icons[6];
|
||||
f = icon.getMinU();
|
||||
f1 = icon.getMaxU();
|
||||
f2 = icon.getMinV();
|
||||
f3 = icon.getMaxV();
|
||||
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glTranslatef(-0.5F, 0.7F, 0F);
|
||||
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Apr 9, 2015, 5:35:26 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.item.IBaubleRender.Helper;
|
||||
import vazkii.botania.api.subtile.signature.SubTileSignature;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.common.block.BlockModFlower;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.version.VersionChecker;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.item.material.ItemManaResource;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public final class ContributorFancinessHandler {
|
||||
|
||||
private volatile static Map<String, IIcon> flowerMap = null;
|
||||
private static boolean startedLoading = false;
|
||||
|
||||
public static void render(RenderPlayerEvent.Specials event) {
|
||||
if(!startedLoading) {
|
||||
new ThreadContributorListLoader();
|
||||
startedLoading = true;
|
||||
}
|
||||
|
||||
String name = event.entityPlayer.getDisplayName();
|
||||
|
||||
if(name.equals("Vazkii"))
|
||||
renderFancyExclusiveDevStuffBecauseImAnEvilDevWhoDoesntCareAboutTheCommunityBooo(event);
|
||||
|
||||
name = name.toLowerCase();
|
||||
if(flowerMap != null && flowerMap.containsKey(name))
|
||||
renderFlower(event, flowerMap.get(name));
|
||||
}
|
||||
|
||||
public static void load(Properties props) {
|
||||
flowerMap = new HashMap();
|
||||
for(String key : props.stringPropertyNames()) {
|
||||
String value = props.getProperty(key);
|
||||
|
||||
try {
|
||||
int i = Integer.parseInt(value);
|
||||
if(i < 0 || i >= 16)
|
||||
throw new NumberFormatException();
|
||||
flowerMap.put(key, ModBlocks.flower.func_149735_b(0, i));
|
||||
} catch(NumberFormatException e) {
|
||||
SubTileSignature sig = BotaniaAPI.getSignatureForName(value);
|
||||
if(sig != null)
|
||||
flowerMap.put(key, ItemBlockSpecialFlower.ofType(value).getIconIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void renderFancyExclusiveDevStuffBecauseImAnEvilDevWhoDoesntCareAboutTheCommunityBooo(RenderPlayerEvent event) {
|
||||
GL11.glPushMatrix();
|
||||
IIcon icon = ((ItemManaResource) ModItems.manaResource).tailIcon;
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
Helper.translateToHeadLevel(event.entityPlayer);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
float t = 0.13F;
|
||||
GL11.glTranslatef(t, -0.5F, -0.1F);
|
||||
if(event.entityPlayer.motionY < 0)
|
||||
GL11.glRotatef((float) event.entityPlayer.motionY * 20F, 1F, 0F, 0F);
|
||||
|
||||
float r = -18F + (float) Math.sin((ClientTickHandler.ticksInGame + event.partialRenderTick) * 0.05F) * 2F;
|
||||
GL11.glRotatef(r, 0F, 0F, 1F);
|
||||
float s = 0.9F;
|
||||
GL11.glScalef(s, s, s);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glRotatef(-r, 0F, 0F, 1F);
|
||||
GL11.glTranslatef(-t, -0F, 0F);
|
||||
GL11.glScalef(-1F, 1F, 1F);
|
||||
GL11.glTranslatef(t, -0F, 0F);
|
||||
GL11.glRotatef(r, 0F, 0F, 1F);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private static void renderFlower(RenderPlayerEvent event, IIcon icon) {
|
||||
GL11.glPushMatrix();
|
||||
Helper.translateToHeadLevel(event.entityPlayer);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glTranslatef(-0.5F, 0.7F, 0F);
|
||||
|
||||
ShaderHelper.useShader(ShaderHelper.gold);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
ShaderHelper.releaseShader();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static class ThreadContributorListLoader extends Thread {
|
||||
|
||||
public ThreadContributorListLoader() {
|
||||
setName("Botania Contributor Fanciness Thread");
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://raw.githubusercontent.com/Vazkii/Botania/master/contributors.properties");
|
||||
Properties props = new Properties();
|
||||
props.load(new InputStreamReader(url.openStream()));
|
||||
load(props);
|
||||
} catch(Exception e) {
|
||||
FMLLog.info("[Botania] Could not load contributors list. Either you're offline or github is down. Nothing to worry about, carry on~");
|
||||
e.printStackTrace();
|
||||
}
|
||||
VersionChecker.doneChecking = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public final class ShaderHelper {
|
||||
public static int dopplegangerBar = 0;
|
||||
public static int terraPlateRune = 0;
|
||||
public static int filmGrain = 0;
|
||||
public static int gold = 0;
|
||||
|
||||
public static void initShaders() {
|
||||
if(!useShaders())
|
||||
@@ -53,7 +54,8 @@ public final class ShaderHelper {
|
||||
halo = createProgram(null, LibResources.SHADER_HALO_FRAG);
|
||||
dopplegangerBar = createProgram(null, LibResources.SHADER_DOPLLEGANGER_BAR_FRAG);
|
||||
terraPlateRune = createProgram(null, LibResources.SHADER_TERRA_PLATE_RUNE_FRAG);
|
||||
filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN);
|
||||
filmGrain = createProgram(null, LibResources.SHADER_FILM_GRAIN_FRAG);
|
||||
gold = createProgram(null, LibResources.SHADER_GOLD_FRAG);
|
||||
}
|
||||
|
||||
public static void useShader(int shader, ShaderCallback callback) {
|
||||
|
||||
@@ -128,6 +128,7 @@ public final class LibResources {
|
||||
public static final String SHADER_HALO_FRAG = PREFIX_SHADER + "halo.frag";
|
||||
public static final String SHADER_DOPLLEGANGER_BAR_FRAG = PREFIX_SHADER + "doppleganger_bar.frag";
|
||||
public static final String SHADER_TERRA_PLATE_RUNE_FRAG = PREFIX_SHADER + "terra_plate_rune.frag";
|
||||
public static final String SHADER_FILM_GRAIN = PREFIX_SHADER + "film_grain.frag";
|
||||
public static final String SHADER_FILM_GRAIN_FRAG = PREFIX_SHADER + "film_grain.frag";
|
||||
public static final String SHADER_GOLD_FRAG = PREFIX_SHADER + "gold.frag";
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user