ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java

41 lines
1.4 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("ItemFertilizer.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.items;
2015-01-05 22:14:01 +01:00
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
2016-05-16 17:00:29 +02:00
import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize;
2021-05-09 21:58:05 +02:00
import net.minecraft.block.DispenserBlock;
2021-08-22 23:19:57 +02:00
import net.minecraft.item.BoneMealItem;
2015-01-05 22:14:01 +01:00
import net.minecraft.item.ItemStack;
2021-08-22 23:19:57 +02:00
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
2015-01-05 22:14:01 +01:00
2019-05-02 09:10:29 +02:00
public class ItemFertilizer extends ItemBase {
public ItemFertilizer() {
2021-08-22 23:19:57 +02:00
super();
2016-05-16 17:00:29 +02:00
DispenserBlock.registerBehavior(this, new DispenserHandlerFertilize());
}
2021-08-22 23:19:57 +02:00
@Override
2021-08-22 23:19:57 +02:00
public ActionResultType useOn(ItemUseContext context) {
ItemStack stack = context.getPlayer().getItemInHand(context.getHand());
if (BoneMealItem.applyBonemeal(stack, context.getLevel(), context.getClickedPos(), context.getPlayer())) {
if (!context.getLevel().isClientSide) {
context.getLevel().levelEvent(2005, context.getClickedPos(), 0);
2015-10-03 10:16:18 +02:00
}
2021-08-22 23:19:57 +02:00
return ActionResultType.SUCCESS;
}
2021-08-22 23:19:57 +02:00
return super.useOn(context);
2015-10-03 10:19:40 +02:00
}
}