November 15, 201411 yr It has nothing todo with the item class... i assume yoy checked if you can fly now? I am the author of Draconic Evolution
November 15, 201411 yr Author It has nothing todo with the item class... i assume yoy checked if you can fly now? Nope, Still can't fly
November 15, 201411 yr Hmmm.... try putting printlns in both sides of the main if statement (the one that sets weather or not the player can fly) and see which one is called I am the author of Draconic Evolution
November 15, 201411 yr Ok thats a bit of a mess... Try this i think i fixed the null pointer and may have figured out why it isnt working. package com.skullcrusher.BetterThings.eventhandlers; import java.util.Map; import java.util.WeakHashMap; import com.skullcrusher.BetterThings.BetterThings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; public class ArmorEventHandler { public static Map<EntityPlayer, Boolean> playersWithFlight = new WeakHashMap<EntityPlayer, Boolean>(); @SubscribeEvent public void onEntityUpdate(PlayerTickEvent event) { if (event.phase != TickEvent.Phase.START || event.player.worldObj.isRemote) return; System.out.println("Equipment Stack "+event.player.getEquipmentInSlot(3)); if (event.player.getEquipmentInSlot(3) != null) System.out.println("Item "+event.player.getEquipmentInSlot(3).getItem()); System.out.println("Target Item "+BetterThings.GravityChestplate); System.out.println(event.player.getEquipmentInSlot(3) != null && event.player.getEquipmentInSlot(3).getItem() == BetterThings.GravityChestplate); if (event.player.getEquipmentInSlot(3) != null && event.player.getEquipmentInSlot(3).getItem() == BetterThings.GravityChestplate) { playersWithFlight.put(event.player, true); event.player.capabilities.allowFlying = true; } else { if (!playersWithFlight.containsKey(event.player)) { playersWithFlight.put(event.player, false); } if (playersWithFlight.get(event.player)) { playersWithFlight.put(event.player, false); if (!event.player.capabilities.isCreativeMode) { event.player.capabilities.allowFlying = false; event.player.capabilities.isFlying = false; event.player.sendPlayerAbilities(); } } } } } Ok it worked as we planned When it was on: Equipment Stack 1xitem.GravityChestplate@0 Item com.skullcrusher.BetterThings.Armor.GravityArmor@4aa33ead Target Item com.skullcrusher.BetterThings.Armor.GravityArmor@4aa33ead true When it was off: Equipment Stack null Target Item com.skullcrusher.BetterThings.Armor.GravityArmor@4aa33ead false did you copy just the changes or the entire class? I am the author of Draconic Evolution
November 15, 201411 yr OOOh change if (event.phase != TickEvent.Phase.START || event.player.worldObj.isRemote) return; to if (event.phase != TickEvent.Phase.START || !event.player.worldObj.isRemote) return; and that should do the trick. Edit infact remove the isRemote altogether if (event.phase != TickEvent.Phase.START) return; I am the author of Draconic Evolution
November 15, 201411 yr Author Hmmm.... try putting printlns in both sides of the main if statement (the one that sets weather or not the player can fly) and see which one is called When I was wearing it, It printed "Play is allowed to fly" but when I wasn't it wasn't printing anything but "Equipment Stack null Target Item com.skullcrusher.BetterThings.Armor.GravityArmor@68303e5 false" Code If I put the last print statement in the wrong spot package com.skullcrusher.BetterThings.eventhandlers; import java.util.Map; import java.util.WeakHashMap; import com.skullcrusher.BetterThings.BetterThings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; public class ArmorEventHandler { public static Map<EntityPlayer, Boolean> playersWithFlight = new WeakHashMap<EntityPlayer, Boolean>(); @SubscribeEvent public void onEntityUpdate(PlayerTickEvent event) { if (event.phase != TickEvent.Phase.START || event.player.worldObj.isRemote) return; System.out.println("Equipment Stack "+event.player.getEquipmentInSlot(3)); if (event.player.getEquipmentInSlot(3) != null) System.out.println("Item "+event.player.getEquipmentInSlot(3).getItem()); System.out.println("Target Item "+BetterThings.GravityChestplate); System.out.println(event.player.getEquipmentInSlot(3) != null && event.player.getEquipmentInSlot(3).getItem() == BetterThings.GravityChestplate); if (event.player.getEquipmentInSlot(3) != null && event.player.getEquipmentInSlot(3).getItem() == BetterThings.GravityChestplate) { playersWithFlight.put(event.player, true); event.player.capabilities.allowFlying = true; System.out.println("Allowed Player to fly."); } else { if (!playersWithFlight.containsKey(event.player)) { playersWithFlight.put(event.player, false); } if (playersWithFlight.get(event.player)) { playersWithFlight.put(event.player, false); if (!event.player.capabilities.isCreativeMode) { event.player.capabilities.allowFlying = false; event.player.capabilities.isFlying = false; event.player.sendPlayerAbilities(); System.out.println("Player is not allowed to fly."); } } } } }
November 15, 201411 yr Author OOOh change if (event.phase != TickEvent.Phase.START || event.player.worldObj.isRemote) return; to if (event.phase != TickEvent.Phase.START || !event.player.worldObj.isRemote) return; and that should do the trick. Yes! it worked! Thank you so much!!!!! Putting you in the credits of my mod. Also 1+ karma to you
November 15, 201411 yr Your most welcome! Infact i think you should remove the isRemote altogether I am the author of Draconic Evolution
November 15, 201411 yr Author Your most welcome! Infact i think you should remove the isRemote altogether I removed it and it didn't calculate fall damage after I took the gravity chestplate off midair. So I left it there and it calculates fall damage just fine
November 15, 201411 yr Oh i see its in the wrong spot it should be here if (playersWithFlight.get(player) && !player.worldObj.isRemote) { //<--- playersWithFlight.put(player, false); if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; player.capabilities.isFlying = false; player.sendPlayerAbilities(); } } But if its working for you it probably dosnt matter. I am the author of Draconic Evolution
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.