mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
Move paper handling to event. Refactor code for readabalitiy.
This commit is contained in:
1 parent
e05768b801
commit
794e953f01
2 files changed
+48
-31
No files matched your search
@@ -89,28 +89,9 @@ public class TinkerToolEvents
|
||||
}
|
||||
}
|
||||
|
||||
int thaum = 0;
|
||||
if (toolTag.getInteger("Head") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Handle") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Accessory") == 31)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Extra") == 31)
|
||||
thaum++;
|
||||
|
||||
if ((thaum >= 3) || (!toolTag.hasKey("Accessory") && thaum >= 2))
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 2;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else if (thaum >= 1)
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
// bonus modifiers
|
||||
handlePaper(toolTag, event.tool);
|
||||
handleThaumium(toolTag, event.tool);
|
||||
|
||||
if (event.tool == TinkerTools.shortbow)
|
||||
{
|
||||
@@ -171,6 +152,50 @@ public class TinkerToolEvents
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePaper(NBTTagCompound toolTag, ToolCore tool)
|
||||
{
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper)
|
||||
modifiers++;
|
||||
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Paper)
|
||||
modifiers++;
|
||||
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Paper)
|
||||
modifiers++;
|
||||
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Paper)
|
||||
modifiers++;
|
||||
|
||||
// 2 part tools gain 2 modifiers for the head
|
||||
if(tool.getPartAmount() == 2 && toolTag.getInteger("Head") == TinkerTools.MaterialID.Paper)
|
||||
modifiers++;
|
||||
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
private void handleThaumium(NBTTagCompound toolTag, ToolCore tool)
|
||||
{
|
||||
// count thaumic parts
|
||||
int thaum = 0;
|
||||
if (toolTag.getInteger("Head") == TinkerTools.MaterialID.Thaumium)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Handle") == TinkerTools.MaterialID.Thaumium)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Accessory") == TinkerTools.MaterialID.Thaumium)
|
||||
thaum++;
|
||||
if (toolTag.getInteger("Extra") == TinkerTools.MaterialID.Thaumium)
|
||||
thaum++;
|
||||
|
||||
// each part gives 0.5 modifiers, rounded up
|
||||
int bonusModifiers = (int) Math.ceil((double)thaum/2d);
|
||||
|
||||
// 2-part tools get 1 modifier per part
|
||||
if(tool.getPartAmount() == 2)
|
||||
bonusModifiers = thaum;
|
||||
|
||||
int modifiers = toolTag.getInteger("Modifiers");
|
||||
modifiers += bonusModifiers;
|
||||
toolTag.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
private boolean allowCrafting (int head, int handle, int accessory)
|
||||
{
|
||||
int[] nonMetals = { 0, 1, 3, 4, 5, 6, 7, 8, 9, 17 };
|
||||
|
||||
Reference in new issue
Block a user