diff --git a/src/main/java/biomesoplenty/client/render/items/BiomeFinderRenderer.java b/src/main/java/biomesoplenty/client/render/items/BiomeFinderRenderer.java index 77c0ec893..3b7fc7558 100644 --- a/src/main/java/biomesoplenty/client/render/items/BiomeFinderRenderer.java +++ b/src/main/java/biomesoplenty/client/render/items/BiomeFinderRenderer.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.IItemRenderer; @@ -24,13 +25,10 @@ import cpw.mods.fml.relauncher.SideOnly; public class BiomeFinderRenderer implements IItemRenderer { - private int tickCount = 0; - private int loopIndex = 0; - private static ResourceLocation radarLocation = new ResourceLocation("biomesoplenty:textures/items/biomeradarstatic.png"); - public double currentAngle; - public double angleDelta; + private double[] currentAngles = new double[BiomeGenBase.func_150565_n().length]; + private double[] angleDeltas = new double[BiomeGenBase.func_150565_n().length]; @Override @SideOnly(Side.CLIENT) @@ -50,13 +48,18 @@ public class BiomeFinderRenderer implements IItemRenderer @SideOnly(Side.CLIENT) public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + Tessellator tessellator = Tessellator.instance; - IIcon radarIcon = ((ItemBiomeFinder)BOPItemHelper.get("biomeFinder")).radarIcon; - - int index = getIconIndexFacingBiome(item); - - GL11.glEnable(3042); + NBTTagCompound stackCompound = item != null ? item.getTagCompound() : null; + int biomeID = stackCompound != null ? stackCompound.getInteger("biomeIDToFind") : 0; + boolean foundBiome = stackCompound != null ? stackCompound.getBoolean("foundBiome") : false; + NBTTagCompound biomePositionCompound = stackCompound != null ? stackCompound.getCompoundTag("biomePosition") : null; + + ItemBiomeFinder biomeFinder = ((ItemBiomeFinder)BOPItemHelper.get("biomeFinder")); + + IIcon radarIcon = foundBiome ? biomeFinder.biomeRadarIcons[getIconIndexFacingBiome(biomeID, biomePositionCompound)] : biomeFinder.getIconFromDamage(0); if (type.equals(IItemRenderer.ItemRenderType.ENTITY)) { @@ -66,104 +69,81 @@ public class BiomeFinderRenderer implements IItemRenderer TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.bindTexture(texturemanager.getResourceLocation(item.getItemSpriteNumber())); - float f = (float)(0.01D / radarIcon.getIconWidth()); - // (originX ) - float minU = ((index * 15F) / radarIcon.getIconWidth() + f) / 2; - float maxU = (((index * 15F) + 16F) / radarIcon.getIconWidth() - f) / 2; - float minV = ((0 * 15F) / radarIcon.getIconHeight() + f); - float maxV = (((0 * 15F) + 16F) / radarIcon.getIconHeight() - f); - GL11.glBlendFunc(770, 771); if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { - RenderUtils.renderIcon(index, 0, minU, maxU, minV, maxV, 0.001D); + RenderUtils.renderIcon(radarIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); } - else + else { - ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, radarIcon.getIconWidth(), radarIcon.getIconHeight(), 0.0625F); + ItemRenderer.renderItemIn2D(tessellator, radarIcon.getMaxU(), radarIcon.getMinV(), radarIcon.getMinU(), radarIcon.getMaxV(), radarIcon.getIconWidth(), radarIcon.getIconHeight(), 0.0625F); } - - GL11.glDisable(3042); + GL11.glPopMatrix(); } - private int getIconIndexFacingBiome(ItemStack itemStack) + @SideOnly(Side.CLIENT) + private int getIconIndexFacingBiome(int biomeID, NBTTagCompound biomePositionCompound) { - Minecraft minecraft = Minecraft.getMinecraft(); - World world = minecraft.theWorld; - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + Minecraft minecraft = Minecraft.getMinecraft(); + World world = minecraft.theWorld; + EntityPlayer player = Minecraft.getMinecraft().thePlayer; - NBTTagCompound stackCompound = itemStack != null ? itemStack.getTagCompound() : null; - boolean foundBiome = stackCompound != null ? stackCompound.getBoolean("foundBiome") : false; - NBTTagCompound biomePositionCompound = stackCompound != null ? stackCompound.getCompoundTag("biomePosition") : null; + if (biomePositionCompound != null) + { + double playerPosX = player.posX; + double playerPosZ = player.posZ; + int biomePosX = biomePositionCompound.getInteger("x"); + int biomePosZ = biomePositionCompound.getInteger("z"); + + System.out.println(biomePosX); - if (foundBiome) - { - double playerPosX = player.posX; - double playerPosZ = player.posZ; - int biomePosX = biomePositionCompound.getInteger("x"); - int biomePosZ = biomePositionCompound.getInteger("z"); + double d3 = 0.0D; - double d3 = 0.0D; + if (world != null) + { + double d4 = (double)biomePosX - playerPosX; + double d5 = (double)biomePosZ - playerPosZ; + player.rotationYaw %= 360.0D; + d3 = -((player.rotationYaw - 90.0D) * Math.PI / 180.0D - Math.atan2(d5, d4)); + } - if (world != null) - { - double d4 = (double)biomePosX - playerPosX; - double d5 = (double)biomePosZ - playerPosZ; - player.rotationYaw %= 360.0D; - d3 = -((player.rotationYaw - 90.0D) * Math.PI / 180.0D - Math.atan2(d5, d4)); - } + double d6; - double d6; + for (d6 = d3 - this.currentAngles[biomeID]; d6 < -Math.PI; d6 += (Math.PI * 2D)) + { + ; + } - for (d6 = d3 - this.currentAngle; d6 < -Math.PI; d6 += (Math.PI * 2D)) - { - ; - } + while (d6 >= Math.PI) + { + d6 -= (Math.PI * 2D); + } - while (d6 >= Math.PI) - { - d6 -= (Math.PI * 2D); - } + if (d6 < -1.0D) + { + d6 = -1.0D; + } - if (d6 < -1.0D) - { - d6 = -1.0D; - } + if (d6 > 1.0D) + { + d6 = 1.0D; + } - if (d6 > 1.0D) - { - d6 = 1.0D; - } + this.angleDeltas[biomeID] += d6 * 0.1D; + this.angleDeltas[biomeID] *= 0.8D; + this.currentAngles[biomeID] += this.angleDeltas[biomeID]; - this.angleDelta += d6 * 0.1D; - this.angleDelta *= 0.8D; - this.currentAngle += this.angleDelta; + int i; - int i; + for (i = (int)((this.currentAngles[biomeID] / (Math.PI * 2D) + 1.0D) * (double)32) % 32; i < 0; i = (i + 32) % 32) + { + ; + } - for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)32) % 32; i < 0; i = (i + 32) % 32) - { - ; - } - - return i; - } - else - { - if (tickCount++ > 3) - { - if (loopIndex++ < 31) - { - tickCount = 0; - } - else - { - loopIndex = 0; - } - } - - return loopIndex; - } + return i; + } + + return 0; } } diff --git a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java index aacaeee5f..e9609bec9 100755 --- a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java +++ b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java @@ -1,6 +1,5 @@ package biomesoplenty.common.eventhandler; -import cpw.mods.fml.common.FMLCommonHandler; import net.minecraftforge.common.MinecraftForge; import biomesoplenty.common.eventhandler.entity.DyeEventHandler; import biomesoplenty.common.eventhandler.entity.FlippersEventHandler; @@ -17,6 +16,7 @@ import biomesoplenty.common.eventhandler.world.DecorateBiomeEventHandler; import biomesoplenty.common.eventhandler.world.DecorationModificationEventHandler; import biomesoplenty.common.eventhandler.world.MapGenEventHandler; import biomesoplenty.common.eventhandler.world.VillageMaterialEventHandler; +import cpw.mods.fml.common.FMLCommonHandler; public class BOPEventHandlers { diff --git a/src/main/java/biomesoplenty/common/items/ItemBiomeFinder.java b/src/main/java/biomesoplenty/common/items/ItemBiomeFinder.java index 594b439ad..995a1d7cd 100644 --- a/src/main/java/biomesoplenty/common/items/ItemBiomeFinder.java +++ b/src/main/java/biomesoplenty/common/items/ItemBiomeFinder.java @@ -3,6 +3,7 @@ package biomesoplenty.common.items; import java.util.Arrays; import java.util.List; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -18,13 +19,23 @@ import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.WorldChunkManager; import biomesoplenty.BiomesOPlenty; import biomesoplenty.common.network.packet.PacketBiomePosition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemBiomeFinder extends Item { - public IIcon radarIcon; + public IIcon[] biomeRadarIcons = new IIcon[32]; + + private int tickCount = 0; + private int loopIndex = 0; + + public double currentAngle; + public double angleDelta; public ItemBiomeFinder() { + this.setMaxStackSize(1); + this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); } @@ -83,7 +94,7 @@ public class ItemBiomeFinder extends Item ChunkPosition biomePosition = null; - System.out.println((finalFoundPosition1 == null) + " " + (finalFoundPosition2 == null)); + //System.out.println((finalFoundPosition1 == null) + " " + (finalFoundPosition2 == null)); if (finalFoundPosition1 != null && finalFoundPosition2 != null) { @@ -93,8 +104,8 @@ public class ItemBiomeFinder extends Item int f2X = finalFoundPosition2.field_151329_a; int f2Z = finalFoundPosition2.field_151328_c; - System.out.println(f1X + " " + f1Z); - System.out.println(f2X + " " + f2Z); + //System.out.println(f1X + " " + f1Z); + //System.out.println(f2X + " " + f2Z); if (Math.sqrt((f1X * f1X) + (f1Z * f1Z)) > Math.sqrt((f2X * f2X) + (f2Z * f2Z))) biomePosition = finalFoundPosition2; else biomePosition = finalFoundPosition1; @@ -120,7 +131,7 @@ public class ItemBiomeFinder extends Item BiomesOPlenty.packetPipeline.sendTo(new PacketBiomePosition(biomePosition.field_151329_a, biomePosition.field_151328_c, true), (EntityPlayerMP)player); } - System.out.println("Done looking"); + //System.out.println("Done looking"); } } @@ -130,7 +141,12 @@ public class ItemBiomeFinder extends Item @Override public void registerIcons(IIconRegister iconRegister) { - radarIcon = iconRegister.registerIcon("biomesoplenty:biomeradar"); + for (int i = 0; i < 32; i++) + { + this.biomeRadarIcons[i] = iconRegister.registerIcon("biomesoplenty:biomeradar/" + i); + } + + itemIcon = iconRegister.registerIcon("biomesoplenty:biomefinder"); } @Override diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar.png deleted file mode 100644 index 09f73c8ce..000000000 Binary files a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar.png and /dev/null differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/0.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/0.png new file mode 100644 index 000000000..e502bcb31 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/0.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/1.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/1.png new file mode 100644 index 000000000..cb1de4b88 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/1.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/10.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/10.png new file mode 100644 index 000000000..12920126c Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/10.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/11.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/11.png new file mode 100644 index 000000000..d7e158344 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/11.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/12.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/12.png new file mode 100644 index 000000000..b621760f0 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/12.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/13.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/13.png new file mode 100644 index 000000000..ead02ea26 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/13.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/14.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/14.png new file mode 100644 index 000000000..9d9cb5180 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/14.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/15.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/15.png new file mode 100644 index 000000000..75e64953f Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/15.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/16.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/16.png new file mode 100644 index 000000000..13f82e6bf Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/16.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/17.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/17.png new file mode 100644 index 000000000..d1773e7ea Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/17.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/18.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/18.png new file mode 100644 index 000000000..646123200 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/18.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/19.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/19.png new file mode 100644 index 000000000..9b69cc5a2 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/19.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/2.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/2.png new file mode 100644 index 000000000..54d8f8ff1 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/2.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/20.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/20.png new file mode 100644 index 000000000..d66e6cdc0 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/20.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/21.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/21.png new file mode 100644 index 000000000..f7eb65497 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/21.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/22.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/22.png new file mode 100644 index 000000000..7a17b7988 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/22.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/23.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/23.png new file mode 100644 index 000000000..c8f2166e2 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/23.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/24.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/24.png new file mode 100644 index 000000000..07ff8c3a0 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/24.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/25.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/25.png new file mode 100644 index 000000000..4cf6f8826 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/25.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/26.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/26.png new file mode 100644 index 000000000..c32658b27 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/26.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/27.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/27.png new file mode 100644 index 000000000..2235a539b Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/27.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/28.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/28.png new file mode 100644 index 000000000..0865d36e4 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/28.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/29.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/29.png new file mode 100644 index 000000000..3bd2fc96d Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/29.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/3.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/3.png new file mode 100644 index 000000000..7ea40a8f3 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/3.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/30.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/30.png new file mode 100644 index 000000000..73879c8b8 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/30.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/31.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/31.png new file mode 100644 index 000000000..c0f7ae129 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/31.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/4.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/4.png new file mode 100644 index 000000000..3dd8cc6f6 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/4.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/5.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/5.png new file mode 100644 index 000000000..e0f295aeb Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/5.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/6.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/6.png new file mode 100644 index 000000000..f51197952 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/6.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/7.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/7.png new file mode 100644 index 000000000..fbda74bf7 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/7.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/8.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/8.png new file mode 100644 index 000000000..107a32ef2 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/8.png differ diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/9.png b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/9.png new file mode 100644 index 000000000..b7be56fb1 Binary files /dev/null and b/src/main/resources/assets/biomesoplenty/textures/items/biomeradar/9.png differ