mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-24 22:14:45 +00:00
75 lines
2.4 KiB
Java
75 lines
2.4 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as
|
|
* part of the Botania Mod. Get the Source Code in github:
|
|
* https://github.com/Vazkii/Botania
|
|
*
|
|
* Botania is Open Source and distributed under the
|
|
* Botania License: http://botaniamod.net/license.php
|
|
*
|
|
* File Created @ [Dec 4, 2014, 3:28:43 PM (GMT)]
|
|
*/
|
|
package vazkii.botania.api.item;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
|
/**
|
|
* A Bauble Item that implements this will be have hooks to render something on
|
|
* the player while its equipped.
|
|
* This class doesn't extend IBauble to make the API not depend on the Baubles
|
|
* API, but the item in question still needs to implement IBauble.
|
|
*/
|
|
public interface IBaubleRender {
|
|
|
|
/**
|
|
* Called for the rendering of the bauble on the player. The player instance can be
|
|
* acquired through the event parameter. Transformations are already applied for
|
|
* the RenderType passed in. Make sure to check against the type parameter for
|
|
* rendering. Will not be called if the item is a ICosmeticAttachable and
|
|
* has a cosmetic bauble attached to it.
|
|
*/
|
|
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks);
|
|
|
|
/**
|
|
* A few helper methods for the render.
|
|
*/
|
|
public static class Helper {
|
|
|
|
public static void rotateIfSneaking(EntityPlayer player) {
|
|
if(player.isSneaking())
|
|
applySneakingRotation();
|
|
}
|
|
|
|
public static void applySneakingRotation() {
|
|
GlStateManager.translate(0F, 0.2F, 0F);
|
|
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
|
}
|
|
|
|
public static void translateToHeadLevel(EntityPlayer player) {
|
|
GlStateManager.translate(0, -player.getDefaultEyeHeight(), 0);
|
|
if (player.isSneaking())
|
|
GlStateManager.translate(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F);
|
|
}
|
|
|
|
}
|
|
|
|
public static enum RenderType {
|
|
/**
|
|
* Render Type for the player's body, translations apply on the player's rotation.
|
|
* Sneaking is not handled and should be done during the render.
|
|
* @see IBaubleRender.Helper
|
|
*/
|
|
BODY,
|
|
|
|
/**
|
|
* Render Type for the player's body, translations apply on the player's head rotations.
|
|
* Sneaking is not handled and should be done during the render.
|
|
* @see IBaubleRender.Helper
|
|
*/
|
|
HEAD;
|
|
}
|
|
|
|
}
|