mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
added shovel and axe special features
This commit is contained in:
parent
897ce41ac2
commit
4f27b8f4dc
2 changed files with 54 additions and 0 deletions
|
@ -1,9 +1,13 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -40,4 +44,13 @@ public class ItemAxeNA extends ItemAxe implements IModItem, IModelProvider {
|
|||
@Override
|
||||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, IBlockState state) {
|
||||
if (this == ModItems.INFUSED_AXE && state.getMaterial() == Material.LEAVES) {
|
||||
return this.efficiency;
|
||||
} else {
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
package de.ellpeck.naturesaura.items.tools;
|
||||
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -17,6 +29,35 @@ public class ItemShovelNA extends ItemSpade implements IModItem, IModelProvider
|
|||
ModRegistry.addItemOrBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
EnumActionResult result = EnumActionResult.PASS;
|
||||
if (this == ModItems.INFUSED_SHOVEL) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
BlockPos actualPos = pos.add(x, 0, y);
|
||||
if (player.canPlayerEdit(actualPos.offset(facing), facing, stack)) {
|
||||
if (facing != EnumFacing.DOWN
|
||||
&& worldIn.getBlockState(actualPos.up()).getMaterial() == Material.AIR
|
||||
&& worldIn.getBlockState(actualPos).getBlock() == Blocks.GRASS) {
|
||||
if (!worldIn.isRemote) {
|
||||
worldIn.setBlockState(actualPos, Blocks.GRASS_PATH.getDefaultState(), 11);
|
||||
}
|
||||
result = EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result == EnumActionResult.SUCCESS) {
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return this.baseName;
|
||||
|
|
Loading…
Reference in a new issue