mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-05 08:29:09 +01:00
72 lines
2.1 KiB
Java
72 lines
2.1 KiB
Java
/*
|
|
* This file ("ItemDrillUpgrade.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
|
|
* http://ellpeck.de/actaddlicense
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
*
|
|
* © 2015-2016 Ellpeck
|
|
*/
|
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.ActionResult;
|
|
import net.minecraft.util.EnumActionResult;
|
|
import net.minecraft.util.EnumHand;
|
|
import net.minecraft.world.World;
|
|
|
|
public class ItemDrillUpgrade extends ItemBase{
|
|
|
|
public final UpgradeType type;
|
|
|
|
public ItemDrillUpgrade(UpgradeType type, String unlocName){
|
|
super(unlocName);
|
|
this.type = type;
|
|
this.setMaxStackSize(1);
|
|
}
|
|
|
|
public static int getSlotToPlaceFrom(ItemStack stack){
|
|
NBTTagCompound compound = stack.getTagCompound();
|
|
if(compound != null){
|
|
return compound.getInteger("SlotToPlaceFrom")-1;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
|
|
@Override
|
|
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
|
|
if(!world.isRemote && this.type == UpgradeType.PLACER){
|
|
this.setSlotToPlaceFrom(stack, player.inventory.currentItem);
|
|
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
|
}
|
|
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
|
|
}
|
|
|
|
public void setSlotToPlaceFrom(ItemStack stack, int slot){
|
|
NBTTagCompound compound = stack.getTagCompound();
|
|
if(compound == null){
|
|
compound = new NBTTagCompound();
|
|
}
|
|
|
|
compound.setInteger("SlotToPlaceFrom", slot+1);
|
|
|
|
stack.setTagCompound(compound);
|
|
}
|
|
|
|
public enum UpgradeType{
|
|
SPEED,
|
|
SPEED_II,
|
|
SPEED_III,
|
|
SILK_TOUCH,
|
|
FORTUNE,
|
|
FORTUNE_II,
|
|
THREE_BY_THREE,
|
|
FIVE_BY_FIVE,
|
|
PLACER
|
|
}
|
|
}
|