aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/common/items/behaviors/Behaviour_Sense.java
blob: 13e4c583d573d9f4e2910679fee5fa0aec6b3ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package gregtech.common.items.behaviors;

import gregtech.api.items.GT_MetaBase_Item;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.util.GT_LanguageManager;
import ic2.api.crops.ICropTile;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class Behaviour_Sense
  extends Behaviour_None
{
  private final int mCosts;
  
  public Behaviour_Sense(int aCosts)
  {
    this.mCosts = aCosts;
  }
  
  public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ)
  {
    if (aWorld.isRemote) {
      return false;
    }
    TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
    if ((tTileEntity instanceof ICropTile))
    {
      for (int i = -1; i < 2; i++) {
        for (int j = -1; j < 2; j++) {
          for (int k = -1; k < 2; k++) {
            if ((aStack.stackSize > 0) && (((tTileEntity = aWorld.getTileEntity(aX + i, aY + j, aZ + k)) instanceof ICropTile)) && (((ICropTile)tTileEntity).harvest(true)) && (!aPlayer.capabilities.isCreativeMode)) {
              ((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts);
            }
          }
        }
      }
      return true;
    }
    return false;
  }
  
  private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.sense", "Rightclick to harvest Crop Sticks");
  
  public List<String> getAdditionalToolTips(GT_MetaBase_Item aItem, List<String> aList, ItemStack aStack)
  {
    aList.add(this.mTooltip);
    return aList;
  }
}