2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("DispenserHandlerEmptyBucket.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.misc;
|
2015-06-29 20:55:56 +02:00
|
|
|
|
|
|
|
import net.minecraft.block.BlockDispenser;
|
|
|
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
|
|
|
import net.minecraft.dispenser.IBlockSource;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.ItemBucket;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
|
|
|
|
public class DispenserHandlerEmptyBucket extends BehaviorDefaultDispenseItem{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack dispenseStack(IBlockSource source, ItemStack bucket){
|
|
|
|
EnumFacing facing = BlockDispenser.func_149937_b(source.getBlockMetadata());
|
|
|
|
int x = source.getXInt()+facing.getFrontOffsetX();
|
|
|
|
int y = source.getYInt()+facing.getFrontOffsetY();
|
|
|
|
int z = source.getZInt()+facing.getFrontOffsetZ();
|
|
|
|
|
|
|
|
if(source.getWorld().isAirBlock(x, y, z) && !source.getWorld().getBlock(x, y, z).getMaterial().isSolid() && ((ItemBucket)bucket.getItem()).tryPlaceContainedLiquid(source.getWorld(), x, y, z)){
|
|
|
|
return new ItemStack(Items.bucket);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new BehaviorDefaultDispenseItem().dispense(source, bucket);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|