mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-25 22:44:33 +00:00
My God, it's full of stars!
This commit is contained in:
1 parent
e90ae93b51
commit
f27ba20a97
15 files changed
+216
-36
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package fox.spiteful.avaritia;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import fox.spiteful.avaritia.compat.CompatClient;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import fox.spiteful.avaritia.render.CosmicItemRenderer;
|
||||
@@ -24,7 +25,9 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
CompatClient.comprettify();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new LudicrousRenderEvents());
|
||||
LudicrousRenderEvents fancyevents = new LudicrousRenderEvents();
|
||||
MinecraftForge.EVENT_BUS.register(fancyevents);
|
||||
FMLCommonHandler.instance().bus().register(fancyevents);
|
||||
|
||||
ShaderHelper.initShaders();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
@@ -93,7 +94,7 @@ public class LudicrousEvents {
|
||||
for(int x = 0;x < event.toolTip.size();x++){
|
||||
if(event.toolTip.get(x).contains(StatCollector.translateToLocal("attribute.name.generic.attackDamage"))
|
||||
|| event.toolTip.get(x).contains(StatCollector.translateToLocal("Attack Damage"))){
|
||||
event.toolTip.set(x, StatCollector.translateToLocal("plus.infinity") + StatCollector.translateToLocal("attribute.name.generic.attackDamage"));
|
||||
event.toolTip.set(x, EnumChatFormatting.BLUE + "+" + LudicrousText.makeFabulous(StatCollector.translateToLocal("tip.infinity")) + " " + EnumChatFormatting.BLUE + StatCollector.translateToLocal("attribute.name.generic.attackDamage"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package fox.spiteful.avaritia;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class LudicrousText {
|
||||
|
||||
private static final EnumChatFormatting[] fabulousness = new EnumChatFormatting[] {EnumChatFormatting.RED, EnumChatFormatting.GOLD, EnumChatFormatting.YELLOW, EnumChatFormatting.GREEN, EnumChatFormatting.AQUA, EnumChatFormatting.BLUE, EnumChatFormatting.LIGHT_PURPLE};
|
||||
|
||||
public static String makeFabulous(String input) {
|
||||
StringBuilder sb = new StringBuilder(input.length()*3);
|
||||
|
||||
int offset = (int) Math.floor(Minecraft.getSystemTime() / 80.0) % fabulousness.length;
|
||||
|
||||
for (int i=0; i<input.length(); i++) {
|
||||
char c = input.charAt(i);
|
||||
|
||||
int col = (i + fabulousness.length - offset) % fabulousness.length;
|
||||
|
||||
sb.append(fabulousness[col].toString());
|
||||
sb.append(c);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class LudicrousItems {
|
||||
public static Item akashic_record;
|
||||
public static Item armok_orb;
|
||||
|
||||
public static EnumRarity cosmic = EnumHelper.addRarity("COSMIC", EnumChatFormatting.DARK_RED, "Cosmic");
|
||||
public static EnumRarity cosmic = EnumHelper.addRarity("COSMIC", EnumChatFormatting.RED, "Cosmic");
|
||||
|
||||
public static void grind(){
|
||||
resource = new ItemResource();
|
||||
|
||||
@@ -21,11 +21,12 @@ public class ItemSwordInfinity extends ItemSword implements ICosmicRenderItem {
|
||||
|
||||
private static final ToolMaterial opSword = EnumHelper.addToolMaterial("INFINITY_SWORD", 32, 9999, 9999F, -3.0F, 200);
|
||||
private IIcon cosmicMask;
|
||||
private IIcon pommel;
|
||||
|
||||
public ItemSwordInfinity(){
|
||||
super(opSword);
|
||||
setUnlocalizedName("infinity_sword");
|
||||
setTextureName("avaritia:infinity_sword_clean");
|
||||
setTextureName("avaritia:infinity_sword");
|
||||
setCreativeTab(Avaritia.tab);
|
||||
}
|
||||
|
||||
@@ -62,5 +63,21 @@ public class ItemSwordInfinity extends ItemSword implements ICosmicRenderItem {
|
||||
super.registerIcons(ir);
|
||||
|
||||
this.cosmicMask = ir.registerIcon("avaritia:infinity_sword_mask");
|
||||
this.pommel = ir.registerIcon("avaritia:infinity_sword_pommel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass)
|
||||
{
|
||||
if (pass == 1) { return this.pommel; }
|
||||
|
||||
return super.getIcon(stack, pass);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
private float[] lightlevel = new float[3];
|
||||
|
||||
private String[] lightmapobf = new String[] {"lightmapColors", "field_78504_Q", "U"};
|
||||
private static boolean inventoryRender = false;
|
||||
|
||||
public CosmicItemRenderer() {
|
||||
shaderCallback = new ShaderCallback() {
|
||||
@@ -43,11 +44,22 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
public void call(int shader) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
float yaw = 0;
|
||||
float pitch = 0;
|
||||
float scale = 1.0f;
|
||||
|
||||
if (!inventoryRender) {
|
||||
yaw = (float)((mc.thePlayer.rotationYaw * 2 * Math.PI) / 360.0);
|
||||
pitch = - (float)((mc.thePlayer.rotationPitch * 2 * Math.PI) / 360.0);
|
||||
} else {
|
||||
scale = 25.0f;
|
||||
}
|
||||
|
||||
int x = ARBShaderObjects.glGetUniformLocationARB(shader, "yaw");
|
||||
ARBShaderObjects.glUniform1fARB(x, (float)((mc.thePlayer.rotationYaw * 2 * Math.PI) / 360.0));
|
||||
ARBShaderObjects.glUniform1fARB(x, yaw);
|
||||
|
||||
int z = ARBShaderObjects.glGetUniformLocationARB(shader, "pitch");
|
||||
ARBShaderObjects.glUniform1fARB(z, - (float)((mc.thePlayer.rotationPitch * 2 * Math.PI) / 360.0));
|
||||
ARBShaderObjects.glUniform1fARB(z, pitch);
|
||||
|
||||
int l = ARBShaderObjects.glGetUniformLocationARB(shader, "lightlevel");
|
||||
ARBShaderObjects.glUniform3fARB(l, lightlevel[0], lightlevel[1], lightlevel[2]);
|
||||
@@ -55,21 +67,11 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
int lightmix = ARBShaderObjects.glGetUniformLocationARB(shader, "lightmix");
|
||||
ARBShaderObjects.glUniform1fARB(lightmix, 0.2f);
|
||||
|
||||
IIcon[] icons = LudicrousRenderEvents.cosmicIcons;
|
||||
FloatBuffer cosmicUVs = BufferUtils.createFloatBuffer(4 * icons.length);
|
||||
IIcon icon;
|
||||
for (int i=0; i<icons.length; i++) {
|
||||
icon = icons[i];
|
||||
|
||||
cosmicUVs.put(icon.getMinU());
|
||||
cosmicUVs.put(icon.getMinV());
|
||||
cosmicUVs.put(icon.getMaxU());
|
||||
cosmicUVs.put(icon.getMaxV());
|
||||
}
|
||||
cosmicUVs.flip();
|
||||
|
||||
int uvs = ARBShaderObjects.glGetUniformLocationARB(shader, "cosmicuvs");
|
||||
ARBShaderObjects.glUniformMatrix2ARB(uvs, false, cosmicUVs);
|
||||
ARBShaderObjects.glUniformMatrix2ARB(uvs, false, LudicrousRenderEvents.cosmicUVs);
|
||||
|
||||
int s = ARBShaderObjects.glGetUniformLocationARB(shader, "externalScale");
|
||||
ARBShaderObjects.glUniform1fARB(s, scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -129,6 +131,7 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
inventoryRender = true;
|
||||
ShaderHelper.useShader(ShaderHelper.testShader, this.shaderCallback);
|
||||
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
|
||||
IIcon cosmicicon = icri.getMaskTexture(item);
|
||||
@@ -150,6 +153,7 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
t.draw();
|
||||
|
||||
ShaderHelper.releaseShader();
|
||||
inventoryRender = false;
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
@@ -171,20 +175,44 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
|
||||
public void render(ItemStack item) {
|
||||
int dmg = item.getItemDamage();
|
||||
IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 0);
|
||||
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
float scale = 1F / 16F;
|
||||
|
||||
int passes = 1;
|
||||
if (item.getItem().requiresMultipleRenderPasses())
|
||||
{
|
||||
passes = item.getItem().getRenderPasses(item.getItemDamage());
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
|
||||
//ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
|
||||
|
||||
float r,g,b;
|
||||
IIcon icon;
|
||||
float f,f1,f2,f3;
|
||||
float scale = 1F / 16F;
|
||||
|
||||
//Lumberjack.log(Level.INFO, "passes: "+passes);
|
||||
|
||||
for (int i = 0; i < passes; i++)
|
||||
{
|
||||
icon = item.getItem().getIcon(item, i);
|
||||
|
||||
//Lumberjack.log(Level.INFO, "icon "+i+": "+icon);
|
||||
|
||||
f = icon.getMinU();
|
||||
f1 = icon.getMaxU();
|
||||
f2 = icon.getMinV();
|
||||
f3 = icon.getMaxV();
|
||||
|
||||
int colour = item.getItem().getColorFromItemStack(item, i);
|
||||
r = (float)(colour >> 16 & 255) / 255.0F;
|
||||
g = (float)(colour >> 8 & 255) / 255.0F;
|
||||
b = (float)(colour & 255) / 255.0F;
|
||||
GL11.glColor4f(r, g, b, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof ICosmicRenderItem) {
|
||||
ShaderHelper.useShader(ShaderHelper.testShader, this.shaderCallback);
|
||||
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
|
||||
|
||||
@@ -8,6 +8,8 @@ import org.lwjgl.BufferUtils;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
@@ -23,7 +25,7 @@ public class LudicrousRenderEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public static FloatBuffer cosmicUVs = null;
|
||||
public static FloatBuffer cosmicUVs = BufferUtils.createFloatBuffer(4 * cosmicTextures.length);
|
||||
public static IIcon[] cosmicIcons = new IIcon[cosmicTextures.length];
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -37,4 +39,21 @@ public class LudicrousRenderEvents {
|
||||
|
||||
//Lumberjack.log(Level.INFO, "COSMIC QUILTING: "+Arrays.toString(cosmicIcons));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void pushTheCosmicFancinessToTheLimit(RenderTickEvent event) {
|
||||
if (event.phase == Phase.START) {
|
||||
cosmicUVs = BufferUtils.createFloatBuffer(4 * cosmicIcons.length);
|
||||
IIcon icon;
|
||||
for (int i=0; i<cosmicIcons.length; i++) {
|
||||
icon = cosmicIcons[i];
|
||||
|
||||
cosmicUVs.put(icon.getMinU());
|
||||
cosmicUVs.put(icon.getMinV());
|
||||
cosmicUVs.put(icon.getMaxU());
|
||||
cosmicUVs.put(icon.getMaxV());
|
||||
}
|
||||
cosmicUVs.flip();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user