-
Notifications
You must be signed in to change notification settings - Fork 755
/
SoilBlock.java
72 lines (65 loc) · 2.47 KB
/
SoilBlock.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
package tconstruct.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class SoilBlock extends TConstructBlock
{
static String[] soilTypes = new String[] { "slimesand", "grout", "slimesandblue", "graveyardsoil", "consecratedsoil", "slimedirt_blue", "nether_grout" };
public SoilBlock()
{
super(Material.ground, 3.0F, soilTypes);
}
@Override
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
{
if (entity instanceof EntityLivingBase){
if (((EntityLivingBase) entity).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 3)
{
((EntityLivingBase) entity).heal(1);
}
else if (metadata == 4)
{
((EntityLivingBase) entity).attackEntityFrom(DamageSource.magic, 1);
((EntityLivingBase) entity).setFire(1);
}
}
}
}
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta < 3)
{
entity.motionX *= 0.4;
entity.motionZ *= 0.4;
if (meta != 1 && entity instanceof EntityLivingBase)
{
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, 1));
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.jump.id, 1, 1));
}
}
}
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
{
return Blocks.soul_sand.getCollisionBoundingBoxFromPool(world, x, y, z);
}
/*public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
if (world.getBlockMetadata(x, y, z) >= 3)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.875F, 1.0F);
}
}*/
}