-
Notifications
You must be signed in to change notification settings - Fork 754
/
SpeedSlab.java
69 lines (61 loc) · 1.71 KB
/
SpeedSlab.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
package tconstruct.blocks;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import tconstruct.common.TRepo;
import tconstruct.library.TConstructRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SpeedSlab extends SlabBase
{
public SpeedSlab()
{
super(Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(3F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons (IIconRegister iconRegister)
{
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
meta = meta % 8;
return TRepo.speedBlock.getIcon(side, meta);
}
@Override
public void getSubBlocks (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 7; iter++)
{
list.add(new ItemStack(b, 1, iter));
}
}
@Override
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
{
double boost = 2.2D;
int metadata = world.getBlockMetadata(x, y, z) % 8;
if (metadata == 1 || metadata == 4)
boost = 2.7D;
double mX = Math.abs(entity.motionX);
double mZ = Math.abs(entity.motionZ);
if (mX < 0.5D)
{
entity.motionX *= boost;
}
if (mZ < 0.5D)
{
entity.motionZ *= boost;
}
}
}