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
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.event;
|
2015-05-20 22:39:43 +02:00
|
|
|
|
2016-01-08 08:10:55 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.Position;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
2015-05-20 22:39:43 +02:00
|
|
|
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;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
2015-05-20 22:39:43 +02:00
|
|
|
|
|
|
|
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){
|
2016-01-08 08:10:55 +01:00
|
|
|
Block block = Position.fromBlockPos(event.target.getBlockPos()).getBlock(event.world);
|
2015-06-29 20:55:56 +02:00
|
|
|
if(block == fluid){
|
2016-01-08 08:10:55 +01:00
|
|
|
event.world.setBlockToAir(event.target.getBlockPos());
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|