-
Notifications
You must be signed in to change notification settings - Fork 755
/
WoolSlab1Item.java
56 lines (49 loc) · 1.86 KB
/
WoolSlab1Item.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
package tconstruct.items.blocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class WoolSlab1Item extends ItemBlock
{
int blockID;
Block block;
public WoolSlab1Item(int id)
{
super(id);
this.blockID = id + 256;
this.block = Block.blocksList[id + 256];
setMaxDamage(0);
setHasSubtypes(true);
}
public int getMetadata (int meta)
{
return meta;
}
public String getUnlocalizedName (ItemStack par1ItemStack)
{
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 7);
return super.getUnlocalizedName() + "." + ItemDye.dyeColorNames[15 - i] + ".slab";
}
@Override
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
int id = world.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
int trueMeta = meta % 8;
boolean flag = (id & 8) != 0;
if ((side == 1 && flag || side == 0 && !flag) && id == this.blockID && trueMeta == stack.getItemDamage())
{
if (world.setBlock(x, y, z, Block.cloth.blockID, trueMeta, 3))
{
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.block.stepSound.getPlaceSound(),
(this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getPitch() * 0.8F);
--stack.stackSize;
return true;
}
}
return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
}