53 lines
1.8 KiB
Java
53 lines
1.8 KiB
Java
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;
|
|
}
|
|
}
|