ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/event/BucketFillEvent.java

39 lines
1.5 KiB
Java
Raw Normal View History

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-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;
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){
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);
if(block == fluid){
event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ);
event.result = new ItemStack(item);
2015-05-20 22:39:43 +02:00
event.setResult(Event.Result.ALLOW);
}
}
}