summaryrefslogtreecommitdiff
path: root/ihl/i_hate_liquids/IHLEventHandler.java
blob: cd777edbbe2661f38901ee38574b0028b18ef470 (plain)
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
package ihl.i_hate_liquids;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class IHLEventHandler {

	public IHLEventHandler() {}
	
	
	@SubscribeEvent
	public void onBlockBreak(BreakEvent event) 
	{
		World world = event.world;
		if(!world.isRemote)
		{
			int x = event.x;
			int y = event.y;
			int z = event.z;
			Block block = world.getBlock(x, y+1, z);
			if(block.getMaterial().isLiquid())
			{
				InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
				world.spawnEntityInWorld(im);
				return;
			}
			block = world.getBlock(x+1, y, z);
			if(block.getMaterial().isLiquid())
			{
				InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
				world.spawnEntityInWorld(im);
				return;
			}
			block = world.getBlock(x-1, y, z);
			if(block.getMaterial().isLiquid())
			{
				InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
				world.spawnEntityInWorld(im);
				return;
			}
			block = world.getBlock(x, y, z+1);
			if(block.getMaterial().isLiquid())
			{
				InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
				world.spawnEntityInWorld(im);
				return;
			}
			block = world.getBlock(x, y, z-1);
			if(block.getMaterial().isLiquid())
			{
				InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z);
				world.spawnEntityInWorld(im);
				return;
			}
		}
	}
}