Add support for wrenches from other mods.

This commit is contained in:
modmuss50 2017-09-28 21:01:38 +01:00
parent ffe13d0c79
commit 2e1c469524
3 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,33 @@
package techreborn.utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.api.ICustomToolHandler;
public class GenericWrenchHelper implements ICustomToolHandler {
ResourceLocation itemLocation;
boolean damage;
public GenericWrenchHelper(ResourceLocation itemLocation, boolean damage) {
this.itemLocation = itemLocation;
this.damage = damage;
}
@Override
public boolean canHandleTool(ItemStack stack) {
return stack.getItem().getRegistryName().equals(itemLocation);
}
@Override
public boolean handleTool(ItemStack stack, BlockPos pos, World world, EntityPlayer player, EnumFacing side, boolean damage) {
if(this.damage && damage){
stack.damageItem(1, player);
}
return true;
}
}