/**
* 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 @ [22/10/2016, 16:52:36 (GMT)]
*/
package vazkii.botania.common.item.equipment.bauble;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.api.item.IBaubleRender.Helper;
import vazkii.botania.api.item.IBaubleRender.RenderType;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.network.PacketJump;
public class ItemCloudPendant extends CloudPendantShim implements IBaubleRender {
private static int timesJumped;
private static boolean jumpDown;
public ItemCloudPendant(String name) {
super(name);
}
public ItemCloudPendant() {
this(LibItemNames.CLOUD_PENDANT);
}
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.AMULET;
}
@Override
@SideOnly(Side.CLIENT)
public void clientWornTick(ItemStack stack, EntityLivingBase player) {
if(player instanceof EntityPlayerSP && player == Minecraft.getMinecraft().player) {
EntityPlayerSP playerSp = (EntityPlayerSP) player;
UUID uuid = playerSp.getUniqueID();
if(playerSp.onGround)
timesJumped = 0;
else {
if(playerSp.movementInput.jump) {
if(!jumpDown && timesJumped < getMaxAllowedJumps()) {
playerSp.jump();
PacketHandler.sendToServer(new PacketJump());
timesJumped++;
}
jumpDown = true;
} else jumpDown = false;
}
}
}
@Override
@SideOnly(Side.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.translate(-0.2F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.scale(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.cirrusGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F);
}
}
}