2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("ItemWingsOfTheBats.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
2015-07-17 06:51:19 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
2015-07-17 06:51:19 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public class ItemWingsOfTheBats extends ItemBase{
|
2015-07-17 06:51:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A List containing all of the Players that can currently fly
|
|
|
|
* Used so that Flight from other Mods' Items doesn't get broken when
|
|
|
|
* these Wings aren't worn
|
2015-10-02 16:48:01 +02:00
|
|
|
* <p>
|
2015-07-17 12:08:13 +02:00
|
|
|
* Saves Remote Players separately to make de-synced Event Calling
|
|
|
|
* not bug out Capabilities when taking off the Wings
|
2015-10-02 16:48:01 +02:00
|
|
|
* <p>
|
2015-09-27 20:00:14 +02:00
|
|
|
* (Partially excerpted from Botania's Wing System by Vazkii (as I had fiddled around with the system and couldn't make it work) with permission, thanks!)
|
2015-07-17 06:51:19 +02:00
|
|
|
*/
|
2015-07-17 23:22:10 +02:00
|
|
|
public static ArrayList<String> wingedPlayers = new ArrayList<String>();
|
2015-07-17 06:51:19 +02:00
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public ItemWingsOfTheBats(String name){
|
|
|
|
super(name);
|
2015-07-17 06:51:19 +02:00
|
|
|
this.setMaxStackSize(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the Player is winged
|
2015-10-02 16:48:01 +02:00
|
|
|
*
|
2015-07-17 06:51:19 +02:00
|
|
|
* @param player The Player
|
|
|
|
* @return Winged?
|
|
|
|
*/
|
|
|
|
public static boolean isPlayerWinged(EntityPlayer player){
|
|
|
|
return wingedPlayers.contains(player.getUniqueID()+(player.worldObj.isRemote ? "-Remote" : ""));
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
/**
|
|
|
|
* Same as above, but Remote Checking is done automatically
|
|
|
|
*/
|
|
|
|
public static void removeWingsFromPlayer(EntityPlayer player){
|
|
|
|
removeWingsFromPlayer(player, player.worldObj.isRemote);
|
|
|
|
}
|
|
|
|
|
2015-07-17 06:51:19 +02:00
|
|
|
/**
|
|
|
|
* Removes the Player from the List of Players that have Wings
|
2015-10-02 16:48:01 +02:00
|
|
|
*
|
|
|
|
* @param player The Player
|
2015-07-17 06:51:19 +02:00
|
|
|
* @param worldRemote If the World the Player is in is remote
|
|
|
|
*/
|
|
|
|
public static void removeWingsFromPlayer(EntityPlayer player, boolean worldRemote){
|
|
|
|
wingedPlayers.remove(player.getUniqueID()+(worldRemote ? "-Remote" : ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the Player to the List of Players that have Wings
|
2015-10-02 16:48:01 +02:00
|
|
|
*
|
2015-07-17 06:51:19 +02:00
|
|
|
* @param player The Player
|
|
|
|
*/
|
|
|
|
public static void addWingsToPlayer(EntityPlayer player){
|
|
|
|
wingedPlayers.add(player.getUniqueID()+(player.worldObj.isRemote ? "-Remote" : ""));
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:16:18 +02:00
|
|
|
/**
|
|
|
|
* Checks if the Player has Wings in its Inventory
|
|
|
|
*
|
|
|
|
* @param player The Player
|
|
|
|
* @return The Wings
|
|
|
|
*/
|
|
|
|
public static ItemStack getWingItem(EntityPlayer player){
|
|
|
|
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
|
|
|
|
if(player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats){
|
|
|
|
return player.inventory.getStackInSlot(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-07-17 06:51:19 +02:00
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
2016-01-07 21:41:28 +01:00
|
|
|
return EnumRarity.EPIC;
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
2015-07-17 06:51:19 +02:00
|
|
|
}
|