|
| 1 | +package com.dyonovan.neotech.common.items |
| 2 | + |
| 3 | +import com.teambr.bookshelf.client.gui.GuiTextFormat |
| 4 | +import net.minecraft.entity.EntityCreature |
| 5 | +import net.minecraft.entity.passive.EntityAnimal |
| 6 | +import net.minecraft.entity.player.EntityPlayer |
| 7 | +import net.minecraft.item.{EnumAction, ItemStack} |
| 8 | +import net.minecraft.nbt.NBTTagCompound |
| 9 | +import net.minecraft.util.MovingObjectPosition |
| 10 | +import net.minecraft.world.World |
| 11 | +import net.minecraftforge.fml.relauncher.{Side, SideOnly} |
| 12 | + |
| 13 | +/** |
| 14 | + * This file was created for NeoTech |
| 15 | + * |
| 16 | + * NeoTech is licensed under the |
| 17 | + * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License: |
| 18 | + * http://creativecommons.org/licenses/by-nc-sa/4.0/ |
| 19 | + * |
| 20 | + * @author Dyonovan |
| 21 | + * @since 2/10/2016 |
| 22 | + */ |
| 23 | +class ItemAnimalMover extends BaseItem("animalMover", 1) { |
| 24 | + |
| 25 | + override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = { |
| 26 | + player.setItemInUse(stack, getMaxItemUseDuration(stack)) |
| 27 | + stack |
| 28 | + } |
| 29 | + |
| 30 | + override def getItemUseAction(stack: ItemStack): EnumAction = { |
| 31 | + EnumAction.BOW |
| 32 | + } |
| 33 | + |
| 34 | + override def getMaxItemUseDuration(stack: ItemStack): Int = { |
| 35 | + 7200 |
| 36 | + } |
| 37 | + |
| 38 | + override def hasEffect(stack: ItemStack) = stack.hasTagCompound |
| 39 | + |
| 40 | + override def onPlayerStoppedUsing(stack: ItemStack, world: World, player: EntityPlayer, timeLeft: Int): Unit = { |
| 41 | + |
| 42 | + if (timeLeft <= 7180) { |
| 43 | + val mop = getMovingObjectPositionFromPlayer(world, player, false) |
| 44 | + if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && !stack.hasTagCompound) { |
| 45 | + val entity = mop.entityHit |
| 46 | + entity match { |
| 47 | + case mob: EntityCreature => |
| 48 | + val tag = new NBTTagCompound |
| 49 | + mob.writeEntityToNBT(tag) |
| 50 | + stack.writeToNBT(tag) |
| 51 | + case _ => |
| 52 | + } |
| 53 | + } else if (stack.hasTagCompound) { |
| 54 | + val pos = mop.getBlockPos |
| 55 | + |
| 56 | + } |
| 57 | + |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + @SideOnly(Side.CLIENT) |
| 62 | + override def addInformation(stack: ItemStack, player: EntityPlayer, list: java.util.List[String], boolean: Boolean): Unit = { |
| 63 | + if (stack.hasTagCompound) { |
| 64 | + list.add(GuiTextFormat.ITALICS + "Type: " + stack.getTagCompound.getString("EntityId")) |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | +} |
0 commit comments