Guest User

Untitled

a guest
Jan 9th, 2015
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. package com.rwtema.extrautils.crafting;
  2.  
  3. import com.rwtema.extrautils.ExtraUtils;
  4. import com.rwtema.extrautils.item.ItemLawSword;
  5. import cpw.mods.fml.common.FMLCommonHandler;
  6. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  7. import cpw.mods.fml.common.gameevent.TickEvent.Phase;
  8. import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
  9. import cpw.mods.fml.relauncher.Side;
  10. import java.util.Iterator;
  11. import java.util.List;
  12. import java.util.Random;
  13. import net.minecraft.block.BlockFlower;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.item.Item;
  16. import net.minecraft.item.ItemArmor;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.server.MinecraftServer;
  19. import net.minecraft.util.ChatComponentText;
  20.  
  21. public class LawSwordCraftHandler {
  22.  
  23. private final Random rand = new Random();
  24. private final String[] strings = new String[]{"I feel pretty", "Oh, so pretty", "I feel pretty", "and witty and bright!", "All you need is Wuv!"};
  25. private final String flowerType = "tulipPink";
  26. private final int pinkColor = 15892389;
  27.  
  28.  
  29. public static void init() {
  30. FMLCommonHandler.instance().bus().register(new LawSwordCraftHandler());
  31. }
  32.  
  33. @SubscribeEvent
  34. public void event(PlayerTickEvent event) {
  35. if(event.side != Side.CLIENT && event.phase != Phase.END) {
  36. if(this.rand.nextInt(800) == 0) {
  37. if(!this.isPlayerCreative(event)) {
  38. if(this.isPlayerSprinting(event)) {
  39. if(!this.isPlayerAlone()) {
  40. for(int playerList = 0; playerList < 5; ++playerList) {
  41. ItemStack i$ = event.player.func_71124_b(playerList);
  42. if(i$ == null) {
  43. return;
  44. }
  45.  
  46. if(playerList == 0) {
  47. if(!this.isPinkFlower(i$)) {
  48. return;
  49. }
  50. } else {
  51. if(!(i$.func_77973_b() instanceof ItemArmor)) {
  52. return;
  53. }
  54.  
  55. ItemArmor p = (ItemArmor)i$.func_77973_b();
  56. if(p.func_82814_b(i$) != 15892389) {
  57. return;
  58. }
  59. }
  60.  
  61. if(!this.strings[4 - playerList].equals(i$.func_82833_r())) {
  62. return;
  63. }
  64. }
  65.  
  66. if(this.handlePlayer(event.player)) {
  67. List var5 = MinecraftServer.func_71276_C().func_71203_ab().field_72404_b;
  68. Iterator var6 = var5.iterator();
  69.  
  70. while(var6.hasNext()) {
  71. EntityPlayer var7 = (EntityPlayer)var6.next();
  72. var7.func_146105_b((new ChatComponentText(event.player.func_70005_c_())).func_150258_a(" is the Prettiest Pink Princess"));
  73. }
  74.  
  75. event.player.func_146105_b(new ChatComponentText("Thanks to your commitment to exercise and prettiness. You have been granted the greatest gift!"));
  76. }
  77.  
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84.  
  85. public boolean isPinkFlower(ItemStack a) {
  86. return a.func_77973_b() != Item.func_150898_a(BlockFlower.func_149857_e("tulipPink"))?false:a.func_77960_j() == BlockFlower.func_149856_f("tulipPink");
  87. }
  88.  
  89. public boolean isPlayerCreative(PlayerTickEvent event) {
  90. return event.player.field_71075_bZ.field_75098_d;
  91. }
  92.  
  93. public boolean isPlayerSprinting(PlayerTickEvent event) {
  94. return event.player.func_70051_ag();
  95. }
  96.  
  97. public boolean isPlayerAlone() {
  98. return MinecraftServer.func_71276_C().func_71203_ab().field_72404_b.size() <= 1;
  99. }
  100.  
  101. public boolean handlePlayer(EntityPlayer player) {
  102. for(int i = 0; i < player.field_71071_by.func_70302_i_(); ++i) {
  103. ItemStack item = player.field_71071_by.func_70301_a(i);
  104. if(item != null && item.func_77973_b() == ExtraUtils.ethericSword && player.field_71071_by.func_70298_a(i, 1) != null) {
  105. player.field_71071_by.func_70441_a(createNewStack());
  106. return true;
  107. }
  108. }
  109.  
  110. return false;
  111. }
  112.  
  113. public static ItemStack createNewStack() {
  114. return ItemLawSword.newSword();
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment