2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("RenderSpecial.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.misc.special;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
2015-08-25 18:26:23 +02:00
|
|
|
import net.minecraft.block.Block;
|
2015-03-30 18:42:14 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2016-01-08 15:21:05 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-03-31 20:37:55 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-01-07 23:42:42 +01:00
|
|
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
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;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.Vec3d;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
|
2015-03-30 18:42:14 +02:00
|
|
|
public class RenderSpecial{
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-01-08 23:36:35 +01:00
|
|
|
public void render(EntityPlayer player, float partialTicks){
|
|
|
|
if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE)){
|
2015-10-03 10:16:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-07-07 12:32:25 +02:00
|
|
|
|
2015-10-18 19:56:18 +02:00
|
|
|
if(ClientProxy.pumpkinBlurPumpkinBlur){
|
2016-04-20 21:39:03 +02: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
|
|
|
}
|
|
|
|
|
2016-01-09 00:04:30 +01:00
|
|
|
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
|
|
|
|
float size = isBlock ? 0.5F : 0.4F;
|
|
|
|
double offsetUp = isBlock ? 0D : 0.1875D;
|
|
|
|
|
2016-01-20 20:24:16 +01:00
|
|
|
double bobHeight = 0.3;
|
|
|
|
double boop = Minecraft.getSystemTime()/1000D;
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.pushMatrix();
|
2016-01-08 23:36:35 +01:00
|
|
|
|
2016-03-18 23:47:22 +01:00
|
|
|
Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks);
|
|
|
|
Vec3d playerPos = player.getPositionEyes(partialTicks);
|
2016-01-08 23:36:35 +01:00
|
|
|
GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord-(player.isSneaking() || Minecraft.getMinecraft().thePlayer.isSneaking() ? 0.125D : 0D), playerPos.zCoord-currentPos.zCoord);
|
|
|
|
|
2016-01-20 20:24:16 +01:00
|
|
|
GlStateManager.translate(0D, 2.435D+offsetUp, 0D);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
|
|
|
|
GlStateManager.scale(size, size, size);
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2016-01-20 20:30:39 +01:00
|
|
|
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
|
|
|
|
//Peck edit: What do you mean by "nice" you jackass? >_>
|
2016-01-20 20:24:16 +01:00
|
|
|
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*bobHeight, 0D);
|
|
|
|
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
|
2015-03-30 18:42:14 +02:00
|
|
|
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.disableLighting();
|
2015-10-18 19:56:18 +02:00
|
|
|
if(this.theThingToRender != null){
|
2015-11-02 21:38:49 +01:00
|
|
|
if(isBlock){
|
2016-01-11 18:27:47 +01:00
|
|
|
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
2015-12-22 14:55:10 +01:00
|
|
|
AssetUtil.renderBlockInWorld(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage());
|
2015-09-14 00:15:52 +02:00
|
|
|
}
|
|
|
|
else{
|
2016-01-09 00:04:30 +01:00
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
GlStateManager.translate(0D, 0.5D, 0D);
|
|
|
|
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
2016-01-08 23:36:35 +01:00
|
|
|
AssetUtil.renderItemInWorld(this.theThingToRender);
|
2016-01-09 00:04:30 +01:00
|
|
|
GlStateManager.popMatrix();
|
2015-09-14 00:15:52 +02:00
|
|
|
}
|
2015-08-30 22:41:29 +02:00
|
|
|
}
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.enableLighting();
|
2015-08-25 18:26:23 +02:00
|
|
|
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.popMatrix();
|
2015-03-30 18:42:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|