Clean up ic2 support

This commit is contained in:
modmuss50 2018-12-08 20:48:21 +00:00
parent 7db621fbed
commit bb5a3e2647
14 changed files with 116 additions and 110 deletions

View file

@ -24,7 +24,6 @@
package techreborn.items.tools;
import ic2.core.item.tool.ItemTreetap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
@ -47,7 +46,7 @@ import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.PoweredItemContainerProvider;
import reborncore.common.powerSystem.forge.ForgePowerItemManager;
import reborncore.common.util.ItemUtils;
import techreborn.compat.CompatManager;
import techreborn.api.TechRebornAPI;
import techreborn.init.ModItems;
import techreborn.items.ItemTR;
@ -73,11 +72,12 @@ public class ItemElectricTreetap extends ItemTR implements IEnergyItemInfo {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
IEnergyStorage capEnergy = playerIn.getHeldItem(hand).getCapability(CapabilityEnergy.ENERGY, null);
if (CompatManager.isIC2Loaded && block == Block.getBlockFromName("ic2:rubber_wood") && capEnergy.getEnergyStored() >= cost)
if (ItemTreetap.attemptExtract(playerIn, worldIn, pos, side, state, null) && !worldIn.isRemote) {
if(TechRebornAPI.ic2Helper != null && capEnergy.getEnergyStored() >= cost){
if(TechRebornAPI.ic2Helper.extractSap(playerIn, worldIn, pos, side, state, null) && !worldIn.isRemote){
capEnergy.extractEnergy(cost, false);
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}

View file

@ -24,7 +24,6 @@
package techreborn.items.tools;
import ic2.core.item.tool.ItemTreetap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -35,7 +34,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.compat.CompatManager;
import techreborn.api.TechRebornAPI;
import techreborn.events.TRRecipeHandler;
import techreborn.items.ItemTR;
@ -51,15 +50,16 @@ public class ItemTreeTap extends ItemTR {
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
if (CompatManager.isIC2Loaded && block == Block.getBlockFromName("ic2:rubber_wood")) {
ItemTreetap.attemptExtract(playerIn, worldIn, pos, side, state, null);
if (!worldIn.isRemote) {
playerIn.getHeldItem(hand).damageItem(1, playerIn);
if(TechRebornAPI.ic2Helper != null){
if(TechRebornAPI.ic2Helper.extractSap(playerIn, worldIn, pos, side, state, null)){
if (!worldIn.isRemote) {
playerIn.getHeldItem(hand).damageItem(1, playerIn);
}
if (playerIn instanceof EntityPlayerMP) {
TRRecipeHandler.unlockTRRecipes((EntityPlayerMP) playerIn);
}
return EnumActionResult.SUCCESS;
}
if (playerIn instanceof EntityPlayerMP) {
TRRecipeHandler.unlockTRRecipes((EntityPlayerMP) playerIn);
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}

View file

@ -39,7 +39,6 @@ import reborncore.api.IToolHandler;
import reborncore.common.util.RebornPermissions;
import techreborn.compat.CompatManager;
import techreborn.items.ItemTR;
import techreborn.utils.IC2WrenchHelper;
/**
* Created by modmuss50 on 26/02/2016.
@ -57,12 +56,6 @@ public class ItemWrench extends ItemTR implements IToolHandler {
if (!world.isRemote && !PermissionAPI.hasPermission(player.getGameProfile(), RebornPermissions.WRENCH_BLOCK, new BlockPosContext(player, pos, world.getBlockState(pos), facing))) {
return EnumActionResult.PASS;
}
if (CompatManager.isIC2Loaded) {
EnumActionResult result = IC2WrenchHelper.onItemUse(player.getHeldItem(hand), player, world, pos, hand, facing, hitX, hitY, hitZ);
if (result == EnumActionResult.SUCCESS) {
return result;
}
}
return EnumActionResult.PASS;
}