ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java

39 lines
1.4 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("DispenserHandlerFertilize.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;
2016-01-08 13:31:58 +01:00
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
2016-01-08 13:31:58 +01:00
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack){
EnumFacing facing = BlockDispenser.getFacing(source.getBlockMetadata());
int x = source.getBlockTileEntity().getPos().getX()+facing.getFrontOffsetX();
int y = source.getBlockTileEntity().getPos().getY()+facing.getFrontOffsetY();
int z = source.getBlockTileEntity().getPos().getZ()+facing.getFrontOffsetZ();
2016-01-08 13:31:58 +01:00
BlockPos pos = new BlockPos(x, y, z);
if(ItemDye.applyBonemeal(stack, source.getWorld(), pos, null)){
source.getWorld().playAuxSFX(2005, pos, 0);
}
return stack;
}
}