mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 21:20:06 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -7,60 +7,48 @@ import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
public class ModToolRepair extends ItemModifier
|
||||
{
|
||||
public class ModToolRepair extends ItemModifier {
|
||||
|
||||
public ModToolRepair()
|
||||
{
|
||||
public ModToolRepair() {
|
||||
super(new ItemStack[0], 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
public boolean matches(ItemStack[] input, ItemStack tool) {
|
||||
return canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
protected boolean canModify(ItemStack tool, ItemStack[] input) {
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getInteger("Damage") > 0)
|
||||
{
|
||||
if (tags.getInteger("Damage") > 0) {
|
||||
int headID = tags.getInteger("Head");
|
||||
boolean areInputsValid = true;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null && headID != PatternBuilder.instance.getPartID(curInput))
|
||||
{
|
||||
for (ItemStack curInput : input) {
|
||||
if (curInput != null && headID != PatternBuilder.instance.getPartID(curInput)) {
|
||||
areInputsValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areInputsValid)
|
||||
{
|
||||
if (areInputsValid) {
|
||||
return calculateIfNecessary(tool, input);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean calculateIfNecessary (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
private boolean calculateIfNecessary(ItemStack tool, ItemStack[] input) {
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int numInputs = 0;
|
||||
int materialValue = 0;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null)
|
||||
{
|
||||
for (ItemStack curInput : input) {
|
||||
if (curInput != null) {
|
||||
materialValue += PatternBuilder.instance.getPartValue(curInput);
|
||||
numInputs++;
|
||||
}
|
||||
}
|
||||
if (numInputs == 0)
|
||||
return false;
|
||||
if (numInputs == 0) return false;
|
||||
|
||||
int totalRepairValue = calculateIncrease(tool, materialValue, numInputs);
|
||||
float averageRepairValue = totalRepairValue / numInputs;
|
||||
@@ -68,8 +56,7 @@ public class ModToolRepair extends ItemModifier
|
||||
return numInputs == 1 || (damage - totalRepairValue >= -averageRepairValue);
|
||||
}
|
||||
|
||||
private int calculateIncrease (ItemStack tool, int materialValue, int itemsUsed)
|
||||
{
|
||||
private int calculateIncrease(ItemStack tool, int materialValue, int itemsUsed) {
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
@@ -77,27 +64,22 @@ public class ModToolRepair extends ItemModifier
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
float mods = 1.0f;
|
||||
if (modifiers == 2)
|
||||
mods = 0.9f;
|
||||
else if (modifiers == 1)
|
||||
mods = 0.8f;
|
||||
else if (modifiers == 0)
|
||||
mods = 0.7f;
|
||||
if (modifiers == 2) mods = 0.9f;
|
||||
else if (modifiers == 1) mods = 0.8f;
|
||||
else if (modifiers == 0) mods = 0.7f;
|
||||
|
||||
increase *= mods;
|
||||
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
float repairCount = (100 - repair) / 100f;
|
||||
if (repairCount < 0.5f)
|
||||
repairCount = 0.5f;
|
||||
if (repairCount < 0.5f) repairCount = 0.5f;
|
||||
increase *= repairCount;
|
||||
increase /= ((ToolCore) tool.getItem()).getRepairCost();
|
||||
return increase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
public void modify(ItemStack[] input, ItemStack tool) {
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean("Broken", false);
|
||||
int damage = tags.getInteger("Damage");
|
||||
@@ -105,10 +87,8 @@ public class ModToolRepair extends ItemModifier
|
||||
int itemsUsed = 0;
|
||||
|
||||
int materialValue = 0;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null)
|
||||
{
|
||||
for (ItemStack curInput : input) {
|
||||
if (curInput != null) {
|
||||
materialValue += PatternBuilder.instance.getPartValue(curInput);
|
||||
itemsUsed++;
|
||||
}
|
||||
@@ -120,20 +100,16 @@ public class ModToolRepair extends ItemModifier
|
||||
tags.setInteger("RepairCount", repair);
|
||||
|
||||
damage -= increase;
|
||||
if (damage < 0)
|
||||
damage = 0;
|
||||
if (damage < 0) damage = 0;
|
||||
tags.setInteger("Damage", damage);
|
||||
|
||||
AbilityHelper.damageTool(tool, 0, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
public void addMatchingEffect(ItemStack tool) {}
|
||||
|
||||
public boolean validType (IModifyable input)
|
||||
{
|
||||
public boolean validType(IModifyable input) {
|
||||
return input.getModifyType().equals("Tool") || input.getModifyType().equals("Armor");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user