2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("BucketFillEvent.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
|
package ellpeck.actuallyadditions.event;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.Event;
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
|
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
|
|
|
|
import net.minecraft.block.Block;
|
2015-06-29 20:55:56 +02:00
|
|
|
|
import net.minecraft.item.Item;
|
2015-05-20 22:39:43 +02:00
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
|
|
|
|
|
|
|
|
|
public class BucketFillEvent{
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onBucketFilled(FillBucketEvent event){
|
2015-06-29 20:55:56 +02:00
|
|
|
|
this.fillBucket(event, InitItems.itemBucketOil, InitBlocks.blockOil);
|
|
|
|
|
this.fillBucket(event, InitItems.itemBucketCanolaOil, InitBlocks.blockCanolaOil);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillBucket(FillBucketEvent event, Item item, Block fluid){
|
2015-05-20 22:39:43 +02:00
|
|
|
|
Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
|
2015-06-29 20:55:56 +02:00
|
|
|
|
if(block == fluid){
|
2015-06-12 19:12:06 +02:00
|
|
|
|
event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ);
|
2015-06-29 20:55:56 +02:00
|
|
|
|
event.result = new ItemStack(item);
|
2015-05-20 22:39:43 +02:00
|
|
|
|
event.setResult(Event.Result.ALLOW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|