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;
2024-03-02 21:23:08 +01:00
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.DispenserBlock;
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
2024-03-02 21:23:08 +01:00
public InteractionResult useOn(UseOnContext context) {
2021-08-22 23:19:57 +02:00
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
}
2024-03-02 21:23:08 +01:00
return InteractionResult.SUCCESS;
}
2021-08-22 23:19:57 +02:00
return super.useOn(context);
2015-10-03 10:19:40 +02:00
}
}