From 82d5eb36571d9411747146214a1c0fd16cbde637 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 25 Jan 2014 12:56:15 +1100 Subject: [PATCH] Added the basics for biome scrolls, made the position of the biome to find sync on player connection --- .../client/textures/TextureBiomeFinder.java | 2 -- .../biomesoplenty/common/core/BOPItems.java | 2 ++ .../common/eventhandler/BOPEventHandlers.java | 8 ++++++ .../network/ConnectionEventHandler.java | 26 ++++++++++++++++++ .../common/items/ItemBOPBiomeScroll.java | 19 +++++++++++++ .../assets/biomesoplenty/lang/en_US.lang | 1 + .../textures/items/biomescroll.png | Bin 0 -> 287 bytes 7 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/eventhandler/network/ConnectionEventHandler.java create mode 100644 src/main/java/biomesoplenty/common/items/ItemBOPBiomeScroll.java create mode 100644 src/main/resources/assets/biomesoplenty/textures/items/biomescroll.png diff --git a/src/main/java/biomesoplenty/client/textures/TextureBiomeFinder.java b/src/main/java/biomesoplenty/client/textures/TextureBiomeFinder.java index 6aeae1344..97fcd870b 100644 --- a/src/main/java/biomesoplenty/client/textures/TextureBiomeFinder.java +++ b/src/main/java/biomesoplenty/client/textures/TextureBiomeFinder.java @@ -47,8 +47,6 @@ public class TextureBiomeFinder extends TextureAtlasSprite if (par1World != null && !par8) { - //System.out.println(biomePosX + " " + biomePosZ); - double d4 = (double)biomePosX - playerPosX; double d5 = (double)biomePosZ - playerPosZ; par6 %= 360.0D; diff --git a/src/main/java/biomesoplenty/common/core/BOPItems.java b/src/main/java/biomesoplenty/common/core/BOPItems.java index b2e9d171f..7f15e4029 100644 --- a/src/main/java/biomesoplenty/common/core/BOPItems.java +++ b/src/main/java/biomesoplenty/common/core/BOPItems.java @@ -8,6 +8,7 @@ import biomesoplenty.api.BOPBlockHelper; import biomesoplenty.api.BOPItemHelper; import biomesoplenty.common.items.ItemBOPAncientStaff; import biomesoplenty.common.items.ItemBOPAxe; +import biomesoplenty.common.items.ItemBOPBiomeScroll; import biomesoplenty.common.items.ItemBOPFood; import biomesoplenty.common.items.ItemBOPHoe; import biomesoplenty.common.items.ItemBOPMisc; @@ -68,6 +69,7 @@ public class BOPItems //registerItem(new ItemBiomeBook().setUnlocalizedName("biomeBook")); registerItem(new ItemBiomeFinder().setUnlocalizedName("biomeFinder")); + registerItem(new ItemBOPBiomeScroll().setUnlocalizedName("biomeScroll")); registerItem(new ItemBOPSword(BOPItemHelper.toolMaterialMud, 0).setUnlocalizedName("swordMud")); registerItem(new ItemBOPSpade(BOPItemHelper.toolMaterialMud, 0).setUnlocalizedName("shovelMud")); diff --git a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java index df36bfdcf..aacaeee5f 100755 --- a/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java +++ b/src/main/java/biomesoplenty/common/eventhandler/BOPEventHandlers.java @@ -1,5 +1,6 @@ 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; @@ -8,6 +9,7 @@ import biomesoplenty.common.eventhandler.gui.MainMenuEventHandler; import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler; import biomesoplenty.common.eventhandler.misc.BonemealEventHandler; import biomesoplenty.common.eventhandler.misc.CapeEventHandler; +import biomesoplenty.common.eventhandler.network.ConnectionEventHandler; import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler; import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler; import biomesoplenty.common.eventhandler.world.BiomeSizeEventHandler; @@ -20,6 +22,7 @@ public class BOPEventHandlers { public static void init() { + registerNetworkEventHandlers(); registerWorldEventHandlers(); registerEntityEventHandlers(); registerPotionEventHandlers(); @@ -27,6 +30,11 @@ public class BOPEventHandlers registerMiscEventHandlers(); } + private static void registerNetworkEventHandlers() + { + FMLCommonHandler.instance().bus().register(new ConnectionEventHandler()); + } + private static void registerWorldEventHandlers() { MinecraftForge.EVENT_BUS.register(new DecorateBiomeEventHandler()); diff --git a/src/main/java/biomesoplenty/common/eventhandler/network/ConnectionEventHandler.java b/src/main/java/biomesoplenty/common/eventhandler/network/ConnectionEventHandler.java new file mode 100644 index 000000000..d34953bb5 --- /dev/null +++ b/src/main/java/biomesoplenty/common/eventhandler/network/ConnectionEventHandler.java @@ -0,0 +1,26 @@ +package biomesoplenty.common.eventhandler.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import biomesoplenty.BiomesOPlenty; +import biomesoplenty.common.network.packet.PacketBiomePosition; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import cpw.mods.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent; + +public class ConnectionEventHandler +{ + @SubscribeEvent + public void onPlayerLoggedIn(PlayerLoggedInEvent event) + { + EntityPlayer player = (EntityPlayer)event.player; + + NBTTagCompound biomeToFindCompound = player.getEntityData().getCompoundTag("biomePositions").getCompoundTag("Lavender Fields"); + + if (biomeToFindCompound != null) + { + BiomesOPlenty.packetPipeline.sendTo(new PacketBiomePosition("Lavender Fields", biomeToFindCompound.getInteger("x"), biomeToFindCompound.getInteger("z")), (EntityPlayerMP)player); + } + } +} diff --git a/src/main/java/biomesoplenty/common/items/ItemBOPBiomeScroll.java b/src/main/java/biomesoplenty/common/items/ItemBOPBiomeScroll.java new file mode 100644 index 000000000..f40d7ea21 --- /dev/null +++ b/src/main/java/biomesoplenty/common/items/ItemBOPBiomeScroll.java @@ -0,0 +1,19 @@ +package biomesoplenty.common.items; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import biomesoplenty.BiomesOPlenty; + +public class ItemBOPBiomeScroll extends Item +{ + public ItemBOPBiomeScroll() + { + this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); + } + + @Override + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon("biomesoplenty:biomescroll"); + } +} diff --git a/src/main/resources/assets/biomesoplenty/lang/en_US.lang b/src/main/resources/assets/biomesoplenty/lang/en_US.lang index 568559ff0..f6f3effc1 100644 --- a/src/main/resources/assets/biomesoplenty/lang/en_US.lang +++ b/src/main/resources/assets/biomesoplenty/lang/en_US.lang @@ -389,6 +389,7 @@ item.flippers.name=Flippers item.biomeBook.name=Book O' Biomes item.biomeFinder.name=Biome Radar +item.biomeScroll.name=Biome Scroll item.bopBucket.amethyst_empty.name=Amethyst Bucket item.bopBucket.amethyst_spring_water.name=Spring Water Amethyst Bucket diff --git a/src/main/resources/assets/biomesoplenty/textures/items/biomescroll.png b/src/main/resources/assets/biomesoplenty/textures/items/biomescroll.png new file mode 100644 index 0000000000000000000000000000000000000000..7bbe2994ff4cfc4493cc6add5dc90f67f0b170d2 GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L2E{@KYKsA{&S zi(`m||K14)d0P}jTy|D}dljmEL+)FWljyB3-XIp=9W&P_vrT!Ew8_tiaq;`c`?iz5 zua3R=ccUJ|^p)H1OyI?{~Jd$>~gM>^&J4E4H{eIR-9L2%owl^kBN|+1EMz%4Z_@e&Z3?c(>#sdAd1~#s e?9Y9R?~IEd{QVhq{aifInGBw;elF{r5}E+x8fohQ literal 0 HcmV?d00001