2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("DispenserHandlerFertilize.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-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
|
|
|
|
2016-01-08 13:31:58 +01:00
|
|
|
|
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.item.ItemDye;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-06-29 20:55:56 +02:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2015-06-29 20:55:56 +02:00
|
|
|
public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{
|
|
|
|
|
2016-05-29 23:49:35 +02:00
|
|
|
|
2015-06-29 20:55:56 +02:00
|
|
|
@Override
|
|
|
|
public ItemStack dispenseStack(IBlockSource source, ItemStack stack){
|
2016-01-08 08:10:55 +01:00
|
|
|
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);
|
2015-06-29 20:55:56 +02:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
if(ItemDye.applyBonemeal(stack, source.getWorld(), pos)){
|
|
|
|
source.getWorld().playBroadcastSound(2005, pos, 0);
|
2015-06-29 20:55:56 +02:00
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|