Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rwtema.extrautils.crafting;
- import com.rwtema.extrautils.ExtraUtils;
- import com.rwtema.extrautils.item.ItemLawSword;
- import cpw.mods.fml.common.FMLCommonHandler;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- import cpw.mods.fml.common.gameevent.TickEvent.Phase;
- import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
- import cpw.mods.fml.relauncher.Side;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Random;
- import net.minecraft.block.BlockFlower;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemArmor;
- import net.minecraft.item.ItemStack;
- import net.minecraft.server.MinecraftServer;
- import net.minecraft.util.ChatComponentText;
- public class LawSwordCraftHandler {
- private final Random rand = new Random();
- private final String[] strings = new String[]{"I feel pretty", "Oh, so pretty", "I feel pretty", "and witty and bright!", "All you need is Wuv!"};
- private final String flowerType = "tulipPink";
- private final int pinkColor = 15892389;
- public static void init() {
- FMLCommonHandler.instance().bus().register(new LawSwordCraftHandler());
- }
- @SubscribeEvent
- public void event(PlayerTickEvent event) {
- if(event.side != Side.CLIENT && event.phase != Phase.END) {
- if(this.rand.nextInt(800) == 0) {
- if(!this.isPlayerCreative(event)) {
- if(this.isPlayerSprinting(event)) {
- if(!this.isPlayerAlone()) {
- for(int playerList = 0; playerList < 5; ++playerList) {
- ItemStack i$ = event.player.func_71124_b(playerList);
- if(i$ == null) {
- return;
- }
- if(playerList == 0) {
- if(!this.isPinkFlower(i$)) {
- return;
- }
- } else {
- if(!(i$.func_77973_b() instanceof ItemArmor)) {
- return;
- }
- ItemArmor p = (ItemArmor)i$.func_77973_b();
- if(p.func_82814_b(i$) != 15892389) {
- return;
- }
- }
- if(!this.strings[4 - playerList].equals(i$.func_82833_r())) {
- return;
- }
- }
- if(this.handlePlayer(event.player)) {
- List var5 = MinecraftServer.func_71276_C().func_71203_ab().field_72404_b;
- Iterator var6 = var5.iterator();
- while(var6.hasNext()) {
- EntityPlayer var7 = (EntityPlayer)var6.next();
- var7.func_146105_b((new ChatComponentText(event.player.func_70005_c_())).func_150258_a(" is the Prettiest Pink Princess"));
- }
- event.player.func_146105_b(new ChatComponentText("Thanks to your commitment to exercise and prettiness. You have been granted the greatest gift!"));
- }
- }
- }
- }
- }
- }
- }
- public boolean isPinkFlower(ItemStack a) {
- return a.func_77973_b() != Item.func_150898_a(BlockFlower.func_149857_e("tulipPink"))?false:a.func_77960_j() == BlockFlower.func_149856_f("tulipPink");
- }
- public boolean isPlayerCreative(PlayerTickEvent event) {
- return event.player.field_71075_bZ.field_75098_d;
- }
- public boolean isPlayerSprinting(PlayerTickEvent event) {
- return event.player.func_70051_ag();
- }
- public boolean isPlayerAlone() {
- return MinecraftServer.func_71276_C().func_71203_ab().field_72404_b.size() <= 1;
- }
- public boolean handlePlayer(EntityPlayer player) {
- for(int i = 0; i < player.field_71071_by.func_70302_i_(); ++i) {
- ItemStack item = player.field_71071_by.func_70301_a(i);
- if(item != null && item.func_77973_b() == ExtraUtils.ethericSword && player.field_71071_by.func_70298_a(i, 1) != null) {
- player.field_71071_by.func_70441_a(createNewStack());
- return true;
- }
- }
- return false;
- }
- public static ItemStack createNewStack() {
- return ItemLawSword.newSword();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment