-
Notifications
You must be signed in to change notification settings - Fork 755
/
WoolSlab1Item.java
52 lines (46 loc) · 1.84 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
package tconstruct.items.blocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import mantle.blocks.abstracts.MultiItemBlock;
public class WoolSlab1Item extends MultiItemBlock
{
Block block;
public WoolSlab1Item(Block b)
{
super(b, "", "slab", ItemDye.field_150923_a);
this.setSpecialIndex(7, 15);
this.block = b;
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName (ItemStack par1ItemStack)
{
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 7);
return super.getUnlocalizedName() + "." + ItemDye.field_150923_a[7 - 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)
{
Block b = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
int trueMeta = meta % 8;
boolean flag = (b) != null;
if ((side == 1 && flag || side == 0 && !flag) && b == this.block && trueMeta == stack.getItemDamage())
{
if (world.setBlock(x, y, z, Blocks.wool, trueMeta, 3))
{
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.block.stepSound.soundName,
(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);
}
}