2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("RenderSpecial.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2015-11-02 20:55:19 +01:00
|
|
|
* © 2015 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2015-11-02 20:55:19 +01:00
|
|
|
package ellpeck.actuallyadditions.misc.special;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
2015-08-25 18:26:23 +02:00
|
|
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
|
|
|
import net.minecraft.block.Block;
|
2015-03-30 18:42:14 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2015-03-31 20:37:55 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-10-18 19:56:18 +02:00
|
|
|
import net.minecraft.init.Blocks;
|
2015-09-14 00:15:52 +02:00
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-03-30 18:42:14 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
|
2015-03-30 18:42:14 +02:00
|
|
|
public class RenderSpecial{
|
|
|
|
|
2015-03-31 20:37:55 +02:00
|
|
|
private double lastTimeForBobbing;
|
2015-09-14 00:15:52 +02:00
|
|
|
private ItemStack theThingToRender;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-09-14 00:15:52 +02:00
|
|
|
public RenderSpecial(ItemStack stack){
|
|
|
|
this.theThingToRender = stack;
|
2015-03-30 18:42:14 +02:00
|
|
|
}
|
|
|
|
|
2015-11-02 21:38:49 +01:00
|
|
|
public void render(EntityPlayer player){
|
2015-10-03 10:16:18 +02:00
|
|
|
if(player.isInvisible() || player.getHideCape()){
|
|
|
|
return;
|
|
|
|
}
|
2015-07-07 12:32:25 +02:00
|
|
|
|
2015-11-02 21:38:49 +01:00
|
|
|
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
|
|
|
|
float size = isBlock ? 0.3F : 0.4F;
|
|
|
|
float offsetUp = isBlock ? 0F : 0.2F;
|
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
if(ClientProxy.pumpkinBlurPumpkinBlur){
|
2015-10-28 14:46:04 +01:00
|
|
|
this.theThingToRender = new ItemStack(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)%2 == 0 ? Blocks.lit_pumpkin : Blocks.pumpkin);
|
2015-10-18 19:56:18 +02:00
|
|
|
size = 0.3F;
|
|
|
|
offsetUp = 0;
|
|
|
|
}
|
|
|
|
|
2015-03-31 20:37:55 +02:00
|
|
|
int bobHeight = 70;
|
2015-04-04 05:20:19 +02:00
|
|
|
long theTime = Minecraft.getSystemTime();
|
|
|
|
long time = theTime/50;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-03-31 20:37:55 +02:00
|
|
|
if(time-bobHeight >= lastTimeForBobbing){
|
|
|
|
this.lastTimeForBobbing = time;
|
|
|
|
}
|
2015-03-30 18:42:14 +02:00
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
2015-08-25 18:26:23 +02:00
|
|
|
GL11.glTranslated(0D, -0.775D+offsetUp, 0D);
|
2015-03-30 18:42:14 +02:00
|
|
|
GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glScalef(size, size, size);
|
|
|
|
|
2015-06-12 19:12:06 +02:00
|
|
|
if(time-(bobHeight/2) >= lastTimeForBobbing){
|
2015-03-31 20:37:55 +02:00
|
|
|
GL11.glTranslated(0, ((double)time-this.lastTimeForBobbing)/100, 0);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
GL11.glTranslated(0, -((double)time-lastTimeForBobbing)/100+(double)bobHeight/100, 0);
|
|
|
|
}
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-04-04 05:20:19 +02:00
|
|
|
GL11.glRotated((double)theTime/20, 0, 1, 0);
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-08-25 18:26:23 +02:00
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
2015-10-18 19:56:18 +02:00
|
|
|
if(this.theThingToRender != null){
|
2015-11-02 21:38:49 +01:00
|
|
|
if(isBlock){
|
|
|
|
AssetUtil.renderBlock(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage());
|
2015-09-14 00:15:52 +02:00
|
|
|
}
|
|
|
|
else{
|
2015-11-02 21:38:49 +01:00
|
|
|
GL11.glTranslatef(-0.5F, 0F, 0F);
|
|
|
|
AssetUtil.renderItem(this.theThingToRender, 0);
|
2015-09-14 00:15:52 +02:00
|
|
|
}
|
2015-08-30 22:41:29 +02:00
|
|
|
}
|
2015-08-25 18:26:23 +02:00
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
|
2015-03-30 18:42:14 +02:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|