mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +00:00
Flux modified tools now charge properly with the charge rate if CoFHCore is present. WITHOUT breaking blockbreak process. This also fixes moss-repair resetting.
This commit is contained in:
1 parent
78167ba7ac
commit
edf30d3a5c
3 files changed
+49
-7
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -406,23 +407,24 @@ public class AbilityHelper
|
||||
trueSpeed *= 6;
|
||||
if (energy != -1)
|
||||
{
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
// first try charging from the hotbar
|
||||
if (entity instanceof EntityPlayer)
|
||||
int usage = (int)(trueSpeed * 3.3f);
|
||||
// first try charging from the hotbar if we don't have CoFHs override
|
||||
if (equalityOverrideLoaded && entity instanceof EntityPlayer)
|
||||
{
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
// workaround for charging flux-capacitors making tools unusable
|
||||
chargeEnergyFromHotbar(stack, (EntityPlayer) entity, tags);
|
||||
energy = tool.getEnergyStored(stack);
|
||||
}
|
||||
|
||||
if (energy < trueSpeed * 2)
|
||||
if (energy < usage)
|
||||
{
|
||||
if (energy > 0)
|
||||
tags.setInteger("Energy", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
energy -= trueSpeed * 2;
|
||||
energy -= usage*50;
|
||||
tags.setInteger("Energy", energy);
|
||||
|
||||
//stack.setItemDamage(1 + (tool.getMaxEnergyStored(stack) - energy) * (stack.getMaxDamage() - 1) / tool.getMaxEnergyStored(stack));
|
||||
@@ -475,6 +477,8 @@ public class AbilityHelper
|
||||
tags.setInteger("Energy", max - missing);
|
||||
}
|
||||
|
||||
private static boolean equalityOverrideLoaded = Loader.isModLoaded("CoFHCore"); // Mods should be loaded far enough before this is ever initialized
|
||||
|
||||
public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
{
|
||||
tags.getCompoundTag("InfiTool").setBoolean("Broken", true);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cofh.core.item.IEqualityOverrideItem;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
import java.util.*;
|
||||
@@ -47,8 +48,11 @@ import tconstruct.util.config.PHConstruct;
|
||||
* @see ItemModifier
|
||||
*/
|
||||
|
||||
@Optional.Interface(modid = "CoFHLib", iface = "cofh.api.energy.IEnergyContainerItem")
|
||||
public abstract class ToolCore extends Item implements IEnergyContainerItem, IModifyable
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "CoFHLib", iface = "cofh.api.energy.IEnergyContainerItem"),
|
||||
@Optional.Interface(modid = "CoFHCore", iface = "cofh.core.item.IEqualityOverrideItem")
|
||||
})
|
||||
public abstract class ToolCore extends Item implements IEnergyContainerItem, IEqualityOverrideItem, IModifyable
|
||||
{
|
||||
protected Random random = new Random();
|
||||
protected int damageVsEntity;
|
||||
@@ -923,5 +927,30 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
|
||||
// backup
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "CoFHCore")
|
||||
public boolean isLastHeldItemEqual(ItemStack current, ItemStack previous) {
|
||||
if(!current.hasTagCompound() || !previous.hasTagCompound())
|
||||
return false;
|
||||
|
||||
NBTTagCompound curTags = current.getTagCompound();
|
||||
NBTTagCompound prevTags = previous.getTagCompound();
|
||||
if(curTags == prevTags)
|
||||
return true;
|
||||
if(!curTags.hasKey("InfiTool") || !prevTags.hasKey("InfiTool"))
|
||||
return false;
|
||||
|
||||
// create copies so we don't modify the original
|
||||
curTags = (NBTTagCompound) curTags.copy();
|
||||
prevTags = (NBTTagCompound) prevTags.copy();
|
||||
|
||||
curTags.removeTag("Energy");
|
||||
prevTags.removeTag("Energy");
|
||||
curTags.getCompoundTag("InfiTool").removeTag("Damage");
|
||||
prevTags.getCompoundTag("InfiTool").removeTag("Damage");
|
||||
|
||||
return curTags.equals(prevTags);
|
||||
}
|
||||
// end of TE support section
|
||||
}
|
||||
Reference in new issue
Block a user