Really fancy stuff. NOT FANCY ENOUGH.

This commit is contained in:
Alex Spinks committed 2015-07-25 01:16:33 +01:00
1 parent 1dfcaf1be0
commit 3f1a00db68
9 files changed
+354 -47

No files matched your search

@@ -28,8 +28,10 @@ import java.util.Collection;
public class ItemArmorInfinity extends ItemArmor {
public static final ArmorMaterial infinite_armor = EnumHelper.addArmorMaterial("infinity", 9999, new int[]{6, 16, 12, 6}, 1000);
@SideOnly(Side.CLIENT)
public static final ModelArmorInfinity armorModel = new ModelArmorInfinity(1.0f);
public static final ModelArmorInfinity legModel = new ModelArmorInfinity(0.5f);
@SideOnly(Side.CLIENT)
public static final ModelArmorInfinity legModel = new ModelArmorInfinity(0.5f).setLegs(true);
public ItemArmorInfinity(int slot){
super(infinite_armor, 0, slot);
@@ -41,9 +43,9 @@ public class ItemArmorInfinity extends ItemArmor {
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
if(slot == 2)
return "avaritia:textures/models/infinity_pants.png";
else
//if(slot == 2)
// return "avaritia:textures/models/infinity_pants.png";
//else
return "avaritia:textures/models/infinity_armor.png";
}
@@ -96,42 +98,7 @@ public class ItemArmorInfinity extends ItemArmor {
public ModelBiped getArmorModel (EntityLivingBase entityLiving, ItemStack itemstack, int armorSlot){
ModelArmorInfinity model = armorSlot == 2 ? legModel : armorModel;
model.bipedHead.showModel = armorSlot == 0;
model.bipedHeadwear.showModel = armorSlot == 0;
model.bipedBody.showModel = armorSlot == 1;
model.bipedRightArm.showModel = armorSlot == 1;
model.bipedLeftArm.showModel = armorSlot == 1;
model.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3;
model.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3;
model.isSneak = entityLiving.isSneaking();
model.isRiding = entityLiving.isRiding();
model.isChild = entityLiving.isChild();
model.heldItemRight = 0;
model.aimedBow = false;
EntityPlayer player = (EntityPlayer)entityLiving;
ItemStack held_item = player.getEquipmentInSlot(0);
if (held_item != null){
model.heldItemRight = 1;
if (player.getItemInUseCount() > 0){
EnumAction enumaction = held_item.getItemUseAction();
if (enumaction == EnumAction.bow){
model.aimedBow = true;
}else if (enumaction == EnumAction.block){
model.heldItemRight = 3;
}
}
}
model.update(entityLiving, itemstack, armorSlot);
return model;
}
@@ -3,11 +3,15 @@ package fox.spiteful.avaritia.render;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
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 fox.spiteful.avaritia.items.ItemArmorInfinity;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
public class LudicrousRenderEvents {
@@ -33,9 +37,23 @@ public class LudicrousRenderEvents {
cosmicIcons[i] = icon;
}
ModelArmorInfinity.overlayIcon = event.map.registerIcon("avaritia:infinity_armor_mask");
ModelArmorInfinity.invulnOverlayIcon = event.map.registerIcon("avaritia:infinity_armor_mask2");
//Lumberjack.log(Level.INFO, "COSMIC QUILTING: "+Arrays.toString(cosmicIcons));
}
@SubscribeEvent
public void weMadeAQuilt(TextureStitchEvent.Post event) {
if (event.map.getTextureType() == 0) { return; }
CosmicRenderShenanigans.bindItemTexture();
ModelArmorInfinity.itempagewidth = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
ModelArmorInfinity.itempageheight = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
ItemArmorInfinity.armorModel.rebuildOverlay();
ItemArmorInfinity.legModel.rebuildOverlay();
}
@SubscribeEvent
public void pushTheCosmicFancinessToTheLimit(RenderTickEvent event) {
if (event.phase == Phase.START) {
@@ -52,4 +70,14 @@ public class LudicrousRenderEvents {
cosmicUVs.flip();
}
}
@SubscribeEvent
public void makeCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Pre event) {
CosmicRenderShenanigans.inventoryRender = true;
}
@SubscribeEvent
public void finishMakingCosmicStuffLessDumbInGUIs(GuiScreenEvent.DrawScreenEvent.Post event) {
CosmicRenderShenanigans.inventoryRender = false;
}
}
@@ -1,28 +1,271 @@
package fox.spiteful.avaritia.render;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import fox.spiteful.avaritia.Lumberjack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
public class ModelArmorInfinity extends ModelBiped {
public static IIcon overlayIcon = null;
public static IIcon invulnOverlayIcon = null;
public static IIcon eyesIcon = null;
public static ResourceLocation eyeTex = new ResourceLocation("avaritia","textures/models/infinity_armor_eyes.png");
public static int itempagewidth = 0;
public static int itempageheight = 0;
public boolean legs = false;
private Random randy = new Random();
private Overlay overlay;
private Overlay invulnOverlay;
private boolean invulnRender = true;
private float expand;
public ModelArmorInfinity(float expand) {
super(expand, 0, 64,32);
super(expand, 0, 64,64);
this.expand = expand;
this.overlay = new Overlay(this, expand);
this.invulnOverlay = new Overlay(this, 0);
this.bipedHeadwear = new ModelRenderer(this, 32, 0);
this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, expand * 0.5F);
this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + 0, 0.0F);
}
public ModelArmorInfinity setLegs(boolean islegs) {
this.legs = islegs;
int heightoffset = 0;
int legoffset = islegs ? 32 : 0;
this.bipedBody = new ModelRenderer(this, 16, 16 +legoffset);
this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, this.expand);
this.bipedBody.setRotationPoint(0.0F, 0.0F + heightoffset, 0.0F);
this.bipedRightLeg = new ModelRenderer(this, 0, 16 +legoffset);
this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + heightoffset, 0.0F);
this.bipedLeftLeg = new ModelRenderer(this, 0, 16 +legoffset);
this.bipedLeftLeg.mirror = true;
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + heightoffset, 0.0F);
return this;
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
Minecraft mc = Minecraft.getMinecraft();
super.render(entity, f, f1, f2, f3, f4, f5);
CosmicRenderShenanigans.useShader();
CosmicRenderShenanigans.bindItemTexture();
super.render(entity, f, f1, f2, f3, f4, f5);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDepthMask(false);
if(this.invulnRender) {
GL11.glColor4d(1, 1, 1, 0.2);
this.invulnOverlay.render(entity, f, f1, f2, f3, f4, f5);
}
this.overlay.render(entity, f, f1, f2, f3, f4, f5);
CosmicRenderShenanigans.releaseShader();
mc.renderEngine.bindTexture(eyeTex);
GL11.glDisable(GL11.GL_LIGHTING);
mc.entityRenderer.disableLightmap(0.0);
long time = mc.thePlayer.worldObj.getWorldTime();
this.setGems();
double pulse = Math.sin(time / 10.0)*0.5 + 0.5;
GL11.glColor4d(0.84, 1, 0.95, pulse*pulse*pulse*pulse*pulse*pulse*0.5);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
super.render(entity, f, f1, f2, f3, f4, f5);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
if (this.invulnRender) {
long frame = time/3;
randy.setSeed(frame*1723609l);
float o = randy.nextFloat()*6.0f;
float[] col = RainbowHelper.HSVtoRGB(o, 1.0f, 1.0f);
GL11.glColor4d(col[0], col[1], col[2], 1);
this.setEyes();
super.render(entity, f, f1, f2, f3, f4, f5);
}
mc.entityRenderer.enableLightmap(0.0);
GL11.glEnable(GL11.GL_LIGHTING);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
public void update(EntityLivingBase entityLiving, ItemStack itemstack, int armorSlot) {
this.bipedHead.showModel = armorSlot == 0;
this.bipedHeadwear.showModel = armorSlot == 0;
this.bipedBody.showModel = armorSlot == 1 || armorSlot == 2;
this.bipedRightArm.showModel = armorSlot == 1;
this.bipedLeftArm.showModel = armorSlot == 1;
this.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3;
this.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3;
this.overlay.bipedHead.showModel = armorSlot == 0;
this.overlay.bipedHeadwear.showModel = armorSlot == 0;
this.overlay.bipedBody.showModel = armorSlot == 1 || armorSlot == 2;
this.overlay.bipedRightArm.showModel = armorSlot == 1;
this.overlay.bipedLeftArm.showModel = armorSlot == 1;
this.overlay.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3;
this.overlay.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3;
this.isSneak = entityLiving.isSneaking();
this.isRiding = entityLiving.isRiding();
this.isChild = entityLiving.isChild();
this.overlay.isSneak = entityLiving.isSneaking();
this.overlay.isRiding = entityLiving.isRiding();
this.overlay.isChild = entityLiving.isChild();
this.invulnOverlay.isSneak = entityLiving.isSneaking();
this.invulnOverlay.isRiding = entityLiving.isRiding();
this.invulnOverlay.isChild = entityLiving.isChild();
this.heldItemRight = 0;
this.aimedBow = false;
this.overlay.heldItemRight = 0;
this.overlay.aimedBow = false;
this.invulnOverlay.heldItemRight = 0;
this.invulnOverlay.aimedBow = false;
EntityPlayer player = (EntityPlayer)entityLiving;
ItemStack held_item = player.getEquipmentInSlot(0);
if (held_item != null){
this.heldItemRight = 1;
this.overlay.heldItemRight = 1;
this.invulnOverlay.heldItemRight = 1;
if (player.getItemInUseCount() > 0){
EnumAction enumaction = held_item.getItemUseAction();
if (enumaction == EnumAction.bow){
this.aimedBow = true;
this.overlay.aimedBow = true;
this.invulnOverlay.aimedBow = true;
}else if (enumaction == EnumAction.block){
this.heldItemRight = 3;
this.overlay.heldItemRight = 3;
this.invulnOverlay.heldItemRight = 3;
}
}
}
this.invulnRender = armorSlot == 0;
}
public void setEyes() {
this.bipedHead.showModel = false;
this.bipedBody.showModel = false;
this.bipedRightArm.showModel = false;
this.bipedLeftArm.showModel = false;
this.bipedRightLeg.showModel = false;
this.bipedLeftLeg.showModel = false;
this.bipedHeadwear.showModel = true;
}
public void setGems() {
this.bipedHead.showModel = false;
this.bipedHeadwear.showModel = false;
this.bipedBody.showModel = this.legs ? false : true;
this.bipedRightArm.showModel = this.legs ? false : true;
this.bipedLeftArm.showModel = this.legs ? false : true;
this.bipedRightLeg.showModel = this.legs ? true : false;
this.bipedLeftLeg.showModel = this.legs ? true : false;
}
public void rebuildOverlay() {
this.overlay.rebuild(overlayIcon);
this.invulnOverlay.rebuild(invulnOverlayIcon);
}
public class Overlay extends ModelBiped {
public ModelArmorInfinity parent;
public float expand;
public Overlay(ModelArmorInfinity parent, float expand) {
this.parent = parent;
this.expand = expand;
}
public void rebuild(IIcon icon) {
int ox = MathHelper.floor_float(icon.getMinU() * itempagewidth);
int oy = MathHelper.floor_float(icon.getMinV() * itempageheight);
float heightoffset = 0.0f;
int legoffset = this.parent.legs ? 32 : 0;
this.textureWidth = itempagewidth;
this.textureHeight = itempageheight;
this.bipedCloak = new ModelRenderer(this, 0 +ox, 0 +oy);
this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, this.expand);
this.bipedEars = new ModelRenderer(this, 24 +ox, 0 +legoffset +oy);
this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, this.expand);
this.bipedHead = new ModelRenderer(this, 0 +ox, 0 +legoffset +oy);
this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, this.expand);
this.bipedHead.setRotationPoint(0.0F, 0.0F + heightoffset, 0.0F);
this.bipedHeadwear = new ModelRenderer(this, 32 +ox, 0 +legoffset +oy);
this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, this.expand * 0.5F);
this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + heightoffset, 0.0F);
this.bipedBody = new ModelRenderer(this, 16 +ox, 16 +legoffset +oy);
this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, this.expand);
this.bipedBody.setRotationPoint(0.0F, 0.0F + heightoffset, 0.0F);
this.bipedRightArm = new ModelRenderer(this, 40 +ox, 16 +legoffset +oy);
this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + heightoffset, 0.0F);
this.bipedLeftArm = new ModelRenderer(this, 40 +ox, 16 +legoffset +oy);
this.bipedLeftArm.mirror = true;
this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + heightoffset, 0.0F);
this.bipedRightLeg = new ModelRenderer(this, 0 +ox, 16 +legoffset +oy);
this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + heightoffset, 0.0F);
this.bipedLeftLeg = new ModelRenderer(this, 0 +ox, 16 +legoffset +oy);
this.bipedLeftLeg.mirror = true;
this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, this.expand);
this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + heightoffset, 0.0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
}
}
}
@@ -0,0 +1,69 @@
package fox.spiteful.avaritia.render;
public class RainbowHelper {
public static float[] HSVtoRGB(float h, float s, float v)
{
// H is given on [0->6] or -1. S and V are given on [0->1].
// RGB are each returned on [0->1].
float m, n, f;
int i;
float[] hsv = new float[3];
float[] rgb = new float[3];
hsv[0] = h;
hsv[1] = s;
hsv[2] = v;
if (hsv[0] == -1)
{
rgb[0] = rgb[1] = rgb[2] = hsv[2];
return rgb;
}
i = (int) (Math.floor(hsv[0]));
f = hsv[0] - i;
if (i % 2 == 0)
{
f = 1 - f; // if i is even
}
m = hsv[2] * (1 - hsv[1]);
n = hsv[2] * (1 - hsv[1] * f);
switch (i)
{
case 6:
case 0:
rgb[0] = hsv[2];
rgb[1] = n;
rgb[2] = m;
break;
case 1:
rgb[0] = n;
rgb[1] = hsv[2];
rgb[2] = m;
break;
case 2:
rgb[0] = m;
rgb[1] = hsv[2];
rgb[2] = n;
break;
case 3:
rgb[0] = m;
rgb[1] = n;
rgb[2] = hsv[2];
break;
case 4:
rgb[0] = n;
rgb[1] = m;
rgb[2] = hsv[2];
break;
case 5:
rgb[0] = hsv[2];
rgb[1] = m;
rgb[2] = n;
break;
}
return rgb;
}
}