Allow omni tool to work as wrench (#3169). Thanks to Thepigcat76

* Allow omni tool to work as wrench
* Update OmniToolItem.java
This commit is contained in:
thepigcat76 2023-07-28 15:27:38 +02:00 committed by GitHub
parent 1c92b3f382
commit aa4abdfdb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -34,7 +34,9 @@ import net.minecraft.item.Items;
import net.minecraft.item.MiningToolItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.api.IToolHandler;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
@ -44,7 +46,7 @@ import techreborn.init.TRContent;
import techreborn.init.TRToolMaterials;
import techreborn.items.tool.MiningLevel;
public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
public class OmniToolItem extends MiningToolItem implements RcEnergyItem, IToolHandler {
public final int miningLevel;
// 4M FE max charge with 1k charge rate
@ -136,4 +138,14 @@ public class OmniToolItem extends MiningToolItem implements RcEnergyItem {
public RcEnergyTier getTier() {
return RcEnergyTier.EXTREME;
}
@Override
public boolean handleTool(ItemStack stack, BlockPos pos, World world, PlayerEntity player, Direction side, boolean damage) {
if (!player.getWorld().isClient && this.getStoredEnergy(stack) >= 5.0) {
this.tryUseEnergy(stack, (long) 5);
return true;
} else {
return false;
}
}
}

View file

@ -1,9 +1,9 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"D ",
" WD",
" C ",
" S"
"S "
],
"key": {
"D": {
@ -14,7 +14,10 @@
},
"S": {
"item": "minecraft:diamond_sword"
}
},
"W": {
"item": "techreborn:wrench"
}
},
"result": {
"item": "techreborn:omni_tool"