-
Notifications
You must be signed in to change notification settings - Fork 497
/
OilBucketHandler.java
49 lines (35 loc) · 1.34 KB
/
OilBucketHandler.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
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import buildcraft.BuildCraftEnergy;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
public class OilBucketHandler {
@ForgeSubscribe
public void onBucketFill(FillBucketEvent event){
ItemStack result = fillCustomBucket(event.world,event.target);
if(result == null)
return;
event.result=result;
event.setResult(Result.ALLOW);
}
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
int blockID = world.getBlockId(pos.blockX,pos.blockY,pos.blockZ);
if((blockID == BuildCraftEnergy.oilStill.blockID || blockID == BuildCraftEnergy.oilMoving.blockID)
&& world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
world.setBlockWithNotify(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(BuildCraftEnergy.bucketOil);
} else
return null;
}
}