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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 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
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.core.BlockSource;
|
|
|
|
import net.minecraft.core.Direction;
|
|
|
|
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
|
|
|
import net.minecraft.world.item.BoneMealItem;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
2015-06-29 20:55:56 +02:00
|
|
|
|
2021-03-01 17:25:30 +01:00
|
|
|
// TODO: [port][note] might not be needed anymore
|
|
|
|
public class DispenserHandlerFertilize extends DefaultDispenseItemBehavior {
|
2015-06-29 20:55:56 +02:00
|
|
|
|
|
|
|
@Override
|
2024-03-02 21:23:08 +01:00
|
|
|
public ItemStack execute(BlockSource source, ItemStack stack) {
|
2021-08-22 17:09:06 +02:00
|
|
|
Direction facing = source.getBlockState().getValue(BlockStateProperties.FACING);
|
|
|
|
BlockPos pos = source.getPos().relative(facing);
|
2015-06-29 20:55:56 +02:00
|
|
|
|
2021-08-22 17:09:06 +02:00
|
|
|
if (BoneMealItem.growCrop(stack, source.getLevel(), pos)) {
|
|
|
|
source.getLevel().levelEvent(2005, pos, 0);
|
2015-06-29 20:55:56 +02:00
|
|
|
}
|
2016-06-23 19:27:42 +02:00
|
|
|
|
2015-06-29 20:55:56 +02:00
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|