ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java

70 lines
2.6 KiB
Java
Raw Normal View History

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.util.AssetUtil;
2015-03-30 18:42:14 +02:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
2015-03-31 20:37:55 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EnumPlayerModelParts;
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
public class RenderSpecial{
2016-08-04 07:28:58 +02:00
private final ItemStack theThingToRender;
2015-03-30 18:42:14 +02:00
public RenderSpecial(ItemStack stack){
this.theThingToRender = stack;
2015-03-30 18:42:14 +02:00
}
public void render(EntityPlayer player, float partialTicks){
if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){
2015-10-03 10:16:18 +02:00
return;
}
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
2015-03-30 18:42:14 +02:00
GlStateManager.pushMatrix();
2016-03-18 23:47:22 +01:00
Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks);
Vec3d playerPos = player.getPositionEyes(partialTicks);
GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord, playerPos.zCoord-currentPos.zCoord);
GlStateManager.translate(0D, 2.375D-(player.isSneaking() ? 0.125D : 0D)+(isBlock ? 0D : 0.1875D), 0D);
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
float size = isBlock ? 0.5F : 0.4F;
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? >_>
double boop = Minecraft.getSystemTime()/1000D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.25, 0D);
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
2015-03-30 18:42:14 +02:00
GlStateManager.disableLighting();
2015-10-18 19:56:18 +02:00
if(this.theThingToRender != null){
GlStateManager.pushMatrix();
if(!isBlock){
GlStateManager.translate(0D, 0.5D, 0D);
}
GlStateManager.rotate(180F, 1F, 0F, 0F);
AssetUtil.renderItemInWorld(this.theThingToRender);
GlStateManager.popMatrix();
}
GlStateManager.enableLighting();
2015-08-25 18:26:23 +02:00
GlStateManager.popMatrix();
2015-03-30 18:42:14 +02:00
}
}