Advertisement
Guest User

Untitled

a guest
May 10th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. package com.rbs.slurpiesdongles.events;
  2.  
  3. import com.rbs.slurpiesdongles.init.SlurpiesDonglesItems;
  4. import net.minecraft.item.ItemStack;
  5. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  6. import net.minecraftforge.fml.common.gameevent.TickEvent;
  7.  
  8. /**
  9. * Created by RedBu on 3/21/2016.
  10. */
  11. public class EventHandler {
  12. //private static int flytime = 0;
  13.  
  14. @SubscribeEvent
  15. public void onPlayerTick(TickEvent.PlayerTickEvent event) {
  16.  
  17. boolean allowFlying = false;
  18. boolean wasFlyingAllowed = false;
  19. if (event.player.inventory.armorInventory[0] != null && event.player.inventory.armorInventory[1] != null && event.player.inventory.armorInventory[2] != null && event.player.inventory.armorInventory[3] != null) {
  20. ItemStack helmet = event.player.inventory.armorInventory[3];
  21. ItemStack chestplate = event.player.inventory.armorInventory[2];
  22. ItemStack leggings = event.player.inventory.armorInventory[1];
  23. ItemStack boots = event.player.inventory.armorInventory[0];
  24. if (boots.getItem() == SlurpiesDonglesItems.topaz_boots && chestplate.getItem() == SlurpiesDonglesItems.topaz_chestplate && leggings.getItem() == SlurpiesDonglesItems.topaz_leggings && helmet.getItem() == SlurpiesDonglesItems.topaz_helmet) {
  25. allowFlying = true;
  26. wasFlyingAllowed = true;
  27. }
  28. }
  29. if (allowFlying) {
  30. event.player.capabilities.allowFlying = true;
  31. event.player.fallDistance = 0.0F; {
  32. if (wasFlyingAllowed) {
  33. event.player.capabilities.allowFlying = true;
  34. event.player.fallDistance = 0.0F;
  35. }
  36. else if (wasFlyingAllowed) {
  37. wasFlyingAllowed = false; <----- This line here is NOT being used. The "wasFlyingAllowed" part is grayed out and says the statement false was not applied.
  38. }
  39. }
  40.  
  41. if (!event.player.capabilities.isCreativeMode) {
  42. event.player.capabilities.isFlying = false;
  43. event.player.capabilities.allowFlying = false;
  44. }
  45.  
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement