diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index cc55bbcd5..08820da07 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -121,11 +121,11 @@ public final class HUDHandler { profiler.endSection(); } - if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { + /*if(equippedStack != null && equippedStack.getItem() == ModItems.flugelEye) { profiler.startSection("flugelEye"); ItemFlugelEye.renderHUD(event.resolution, mc.thePlayer, equippedStack); profiler.endSection(); - } + }*/ profiler.startSection("manaBar"); EntityPlayer player = mc.thePlayer; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index a141afbb6..7a2df03f8 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -55,6 +55,7 @@ import vazkii.botania.common.Botania; import vazkii.botania.common.achievement.ICraftAchievement; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.core.helper.ItemNBTHelper; +import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibItemNames; import baubles.api.BaubleType; import baubles.common.lib.PlayerHandler; @@ -75,6 +76,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub public static List playersWithFlight = new ArrayList(); private static final int COST = 35; + private static final int COST_OVERKILL = COST * 3; private static final int MAX_FLY_TIME = 400; public static IIcon[] wingIcons; @@ -187,8 +189,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub player.capabilities.allowFlying = true; if(player.capabilities.isFlying) { if(!player.worldObj.isRemote) { - ManaItemHandler.requestManaExact(tiara, player, COST, true); - if(left < 3) + ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); + if(left < 3 && !player.inventory.hasItem(ModItems.flugelEye)) player.setFire(5); } else if(Math.abs(player.motionX) > 0.1 || Math.abs(player.motionZ) > 0.1) { double x = event.entityLiving.posX - 0.5; @@ -283,11 +285,15 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub if(armor != null && armor.getItem() == this) { int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); - return left > (flying ? 0 : MAX_FLY_TIME / 10) && ManaItemHandler.requestManaExact(armor, player, COST, false); + return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItem(ModItems.flugelEye)) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); } return false; } + + public int getCost(ItemStack stack, int timeLeft) { + return timeLeft <= 0 ? COST_OVERKILL : COST; + } @Override public boolean usesMana(ItemStack stack) { diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java index ecbcf8db8..f85c53c25 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java @@ -10,41 +10,108 @@ */ package vazkii.botania.common.item.relic; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.texture.TextureMap; +import javax.swing.Icon; + import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; +import net.minecraft.util.Vec3; import net.minecraft.world.World; -import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.common.MinecraftForge; - -import org.lwjgl.opengl.GL11; - -import vazkii.botania.client.core.handler.ClientTickHandler; -import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class ItemFlugelEye extends ItemRelic { + public ItemFlugelEye() { + super(LibItemNames.FLUGEL_EYE); + } + + private static final String TAG_X = "x"; + private static final String TAG_Y = "y"; + private static final String TAG_Z = "z"; + private static final String TAG_DIMENSION = "dim"; + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + if(player.isSneaking()) { + if(world.isRemote) { + player.swingItem(); + for(int i = 0; i < 10; i++) { + float x1 = (float) (x + Math.random()); + float y1 = (float) (y + 1); + float z1 = (float) (z + Math.random()); + Botania.proxy.wispFX(player.worldObj, x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F); + } + } else { + ItemNBTHelper.setInt(stack, TAG_X, x); + ItemNBTHelper.setInt(stack, TAG_Y, y); + ItemNBTHelper.setInt(stack, TAG_Z, z); + ItemNBTHelper.setInt(stack, TAG_DIMENSION, world.provider.dimensionId); + world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 5F); + } + } + + return true; + } + + @Override + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) { + float x = (float) (player.posX - Math.random() * player.width); + float y = (float) (player.posY - 1.6 + Math.random()); + float z = (float) (player.posZ - Math.random() * player.width); + Botania.proxy.wispFX(player.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F); + } + + @Override + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { + int x = ItemNBTHelper.getInt(stack, TAG_X, 0); + int y = ItemNBTHelper.getInt(stack, TAG_Y, -1); + int z = ItemNBTHelper.getInt(stack, TAG_Z, 0); + int dim = ItemNBTHelper.getInt(stack, TAG_DIMENSION, 0); + + if(y > -1 && dim == world.provider.dimensionId) { + moveParticlesAndSound(player); + if(player instanceof EntityPlayerMP && !world.isRemote) + ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(x + 0.5, y + 1.6, z + 0.5, player.rotationYaw, player.rotationPitch); + moveParticlesAndSound(player); + } + + return stack; + } + + private static void moveParticlesAndSound(Entity entity) { + for(int i = 0; i < 15; i++) { + float x = (float) (entity.posX + Math.random()); + float y = (float) (entity.posY - 1.6 + Math.random()); + float z = (float) (entity.posZ + Math.random()); + Botania.proxy.wispFX(entity.worldObj, x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), -0.3F + (float) Math.random() * 0.2F); + } + if(!entity.worldObj.isRemote) + entity.worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1F, 1F); + } + + @Override + public int getMaxItemUseDuration(ItemStack par1ItemStack) { + return 40; + } + + @Override + public EnumAction getItemUseAction(ItemStack par1ItemStack) { + return EnumAction.block; + } + + /* + // Code from the older iteration of this item: + private static final ResourceLocation glowTexture = new ResourceLocation(LibResources.MISC_GLOW_CYAN); private static final int SEGMENTS = 12; @@ -350,5 +417,6 @@ public class ItemFlugelEye extends ItemRelic { } } + */ }