mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-06-28 15:39:09 +02:00
51 lines
1.7 KiB
Java
51 lines
1.7 KiB
Java
/*
|
|
* This file ("ItemFertilizer.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
|
|
* http://ellpeck.de/actaddlicense
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
*
|
|
* © 2015-2017 Ellpeck
|
|
*/
|
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
|
import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize;
|
|
import net.minecraft.block.BlockDispenser;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.item.EnumRarity;
|
|
import net.minecraft.item.ItemDye;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.EnumActionResult;
|
|
import net.minecraft.util.Direction;
|
|
import net.minecraft.util.Hand;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.World;
|
|
|
|
public class ItemFertilizer extends ItemBase {
|
|
|
|
public ItemFertilizer(String name) {
|
|
super(name);
|
|
|
|
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserHandlerFertilize());
|
|
}
|
|
|
|
@Override
|
|
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction side, float par8, float par9, float par10) {
|
|
ItemStack stack = player.getHeldItem(hand);
|
|
if (ItemDye.applyBonemeal(stack, world, pos, player, hand)) {
|
|
if (!world.isRemote) {
|
|
world.playEvent(2005, pos, 0);
|
|
}
|
|
return EnumActionResult.SUCCESS;
|
|
}
|
|
return super.onItemUse(player, world, pos, hand, side, par8, par9, par10);
|
|
}
|
|
|
|
@Override
|
|
public EnumRarity getRarity(ItemStack stack) {
|
|
return EnumRarity.RARE;
|
|
}
|
|
}
|