78 lines
2.2 KiB
Java
Executable file
78 lines
2.2 KiB
Java
Executable file
package game.item;
|
|
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import game.collect.Sets;
|
|
|
|
import game.entity.attributes.Attribute;
|
|
import game.entity.attributes.AttributeModifier;
|
|
import game.entity.attributes.Attributes;
|
|
import game.entity.npc.EntityNPC;
|
|
import game.init.Items;
|
|
import game.world.World;
|
|
|
|
public class ItemBucketMilk extends Item
|
|
{
|
|
public ItemBucketMilk()
|
|
{
|
|
this.setMaxStackSize(1);
|
|
this.setTab(CheatTab.tabTools);
|
|
}
|
|
|
|
/**
|
|
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
|
|
* the Item before the action is complete.
|
|
*/
|
|
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityNPC playerIn)
|
|
{
|
|
// if (!playerIn.creative)
|
|
// {
|
|
--stack.stackSize;
|
|
// }
|
|
|
|
if (!worldIn.client)
|
|
{
|
|
playerIn.clearEffects(false);
|
|
}
|
|
|
|
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
|
|
return stack.stackSize <= 0 ? new ItemStack(Items.bucket) : stack;
|
|
}
|
|
|
|
/**
|
|
* How long it takes to use or consume an item
|
|
*/
|
|
public int getMaxItemUseDuration(ItemStack stack)
|
|
{
|
|
return 32;
|
|
}
|
|
|
|
/**
|
|
* returns the action that specifies what animation to play when the items is being used
|
|
*/
|
|
public ItemAction getItemUseAction(ItemStack stack)
|
|
{
|
|
return ItemAction.DRINK;
|
|
}
|
|
|
|
/**
|
|
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
|
*/
|
|
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
|
{
|
|
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
|
return itemStackIn;
|
|
}
|
|
|
|
public Map<Attribute, Set<AttributeModifier>> getItemInventoryModifiers()
|
|
{
|
|
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
|
|
multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Milk modifier", -5.0, false, true, true)));
|
|
return multimap;
|
|
}
|
|
|
|
public boolean isMagnetic() {
|
|
return true;
|
|
}
|
|
}
|