-
Notifications
You must be signed in to change notification settings - Fork 755
/
OreberryBushSecondItem.java
90 lines (77 loc) · 2.8 KB
/
OreberryBushSecondItem.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
86
87
88
89
90
package tconstruct.items.blocks;
import java.util.List;
import tconstruct.common.TContent;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OreberryBushSecondItem extends ItemBlock
{
public int blockID;
public OreberryBushSecondItem(int id)
{
super(id);
blockID = id + 256;
setHasSubtypes(true);
}
@Override
public int getMetadata (int meta)
{
return meta % 4;
}
/* Place bushes on dirt, grass, or other bushes only */
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if (side != 1)
return false;
int meta = stack.getItemDamage();
if (meta % 4 != 1 && world.getFullBlockLightValue(x, y + 1, z) >= 13)
return false;
else if (player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack))
{
Block block = Block.blocksList[world.getBlockId(x, y, z)];
if (block != null && block.canSustainPlant(world, x, y, z, ForgeDirection.UP, (IPlantable) TContent.oreBerrySecond) && world.isAirBlock(x, y + 1, z))
{
world.setBlock(x, y + 1, z, blockID, stack.getItemDamage() % 4, 3);
if (!player.capabilities.isCreativeMode)
stack.stackSize--;
if (!world.isRemote)
world.playAuxSFX(2001, x, y, z, blockID);
return true;
}
else
return false;
}
else
return false;
}
/* Block name in inventory */
@Override
public String getUnlocalizedName (ItemStack itemstack)
{
int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1);
return (new StringBuilder()).append("block.oreberry.").append(blockType[pos]).toString();
}
public static final String blockType[] = { "aluminum", "essence", "", "", "aluminum", "essence", "", "", "aluminum", "essence", "", "", "aluminum", "essence", "", "" };
@Override
@SideOnly(Side.CLIENT)
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
{
switch (stack.getItemDamage() % 4)
{
case 0:
list.add("White Chocolate");
break;
case 1:
list.add("Tastes like Creeper");
break;
}
}
}