-
Notifications
You must be signed in to change notification settings - Fork 79
/
ItemMallet.java
85 lines (74 loc) · 2.29 KB
/
ItemMallet.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package mod.chiselsandbits.items;
import java.util.List;
import mod.chiselsandbits.blueprints.EntityBlueprint;
import mod.chiselsandbits.core.ChiselsAndBits;
import mod.chiselsandbits.core.ClientSide;
import mod.chiselsandbits.helpers.LocalStrings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemMallet extends Item
{
public ItemMallet()
{
setMaxStackSize( 1 );
}
@Override
public ActionResult<ItemStack> onItemRightClick(
World world,
EntityPlayer player,
EnumHand hand )
{
return new ActionResult<ItemStack>( findAndInteractWithBlueprint( player, world, hand ), player.getHeldItem( hand ) );
}
@Override
public EnumActionResult onItemUseFirst(
EntityPlayer player,
World world,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ,
EnumHand hand )
{
return findAndInteractWithBlueprint( player, world, hand );
}
public EnumActionResult findAndInteractWithBlueprint(
EntityPlayer player,
World world,
EnumHand hand )
{
EnumActionResult result = EnumActionResult.FAIL;
for ( EntityBlueprint x : world.getEntitiesWithinAABB( EntityBlueprint.class, player.getEntityBoundingBox().expand( 128, 128, 128 ) ) )
{
if ( x.getBlueprintBox().expand( 2, 2, 2 ).intersectsWith( player.getEntityBoundingBox() ) )
{
x.hitWithTool( player, player.getHeldItem( hand ) );
result = EnumActionResult.SUCCESS;
}
}
return result;
}
@Override
@SideOnly( Side.CLIENT )
public void addInformation(
final ItemStack stack,
final World worldIn,
final List<String> tooltip,
final ITooltipFlag advanced )
{
super.addInformation( stack, worldIn, tooltip, advanced );
ChiselsAndBits.getConfig().helpText( LocalStrings.HelpMallet, tooltip, ClientSide.instance.getKeyName( Minecraft.getMinecraft().gameSettings.keyBindUseItem ) );
}
}