Modern toolstation behavior (#294)

This commit is contained in:
FrostyFire1 authored and GitHub committed 2026-06-04 14:45:56 +02:00
1 parent c422066a0f
commit 73ccdde0ee
16 files changed
+241 -61

No files matched your search

@@ -0,0 +1,6 @@
package tconstruct.library.modifier;
import com.github.bsideup.jabel.Desugar;
@Desugar
public record ModificationInfo(int total, int[] toRemove) {}
@@ -8,16 +8,17 @@ import net.minecraft.util.StatCollector;
import tconstruct.library.accessory.AccessoryCore;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.modifiers.tools.ItemModTypeFilter;
public class GloveSpeed extends ItemModTypeFilter {
String tooltipName;
int max = 100;
public GloveSpeed(int effect, ItemStack[] items, int[] values) {
super(effect, "Redstone", items, values);
tooltipName = ("\u00a74" + StatCollector.translateToLocal("modifier.tooltip.Haste"));
this.max = 100;
}
@Override
@@ -27,12 +28,13 @@ public class GloveSpeed extends ItemModTypeFilter {
if (!Arrays.asList(((AccessoryCore) input.getItem()).getTraits()).contains("glove")) return false;
NBTTagCompound tags = getModifierTag(input);
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(modifiers) <= max; // This
// line
// fails?
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(modifiers, input).total() <= max; // This
// line
// fails?
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(modifiers) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(modifiers, input).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
}
@@ -43,7 +45,10 @@ public class GloveSpeed extends ItemModTypeFilter {
public void modify(ItemStack[] modifiers, ItemStack input) {
NBTTagCompound tags = getModifierTag(input);
int[] keyPair;
int increase = matchingAmount(modifiers);
ModificationInfo modificationInfo = matchingAmount(modifiers, input);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
keyPair = tags.getIntArray(key);
if (keyPair[0] % max == 0) {
@@ -4,12 +4,15 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ItemModifier;
import tconstruct.library.modifier.ModificationInfo;
public abstract class ItemModTypeFilter extends ItemModifier {
public final List<Integer> increase;
protected int max;
public ItemModTypeFilter(int effect, String dataKey, ItemStack[] items, int[] values) {
super(items, effect, dataKey);
@@ -51,21 +54,67 @@ public abstract class ItemModTypeFilter extends ItemModifier {
return minimumMatch;
}
public int matchingAmount(ItemStack[] input) {
// Needed because Lapis modifier does not put its max in the keyPair
public ModificationInfo matchingAmount(ItemStack[] input, ItemStack tool) {
return matchingAmount(input, tool, max);
}
public ModificationInfo matchingAmount(ItemStack[] input, ItemStack tool, int modifierMax) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int availableAmount;
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] % modifierMax == 0) {
availableAmount = modifierMax;
} else {
// Blame Lapis modifier
int upperLimit = keyPair.length == 2 ? modifierMax : keyPair[1];
availableAmount = upperLimit - keyPair[0];
}
} else {
availableAmount = modifierMax;
}
int amount = 0;
ArrayList<Integer> toRemove = new ArrayList<>();
for (ItemStack inputStack : input) {
if (inputStack != null) {
for (int iter = 0; iter < stacks.size(); iter++) {
ItemStack stack = (ItemStack) stacks.get(iter);
if (stack.getItemDamage() == Short.MAX_VALUE) {
if (this.areItemsEquivalent(inputStack, stack)) amount += increase.get(iter);
} else {
if (this.areItemStacksEquivalent(inputStack, stack)) amount += increase.get(iter);
if (inputStack == null) {
continue;
}
for (int iter = 0; iter < stacks.size(); iter++) {
ItemStack stack = stacks.get(iter);
int perItemIncrease = increase.get(iter);
int maxItems = availableAmount / perItemIncrease;
int itemsUsed;
int usedAmount = 0;
if (stack.getItemDamage() == Short.MAX_VALUE) {
if (this.areItemsEquivalent(inputStack, stack)) {
itemsUsed = Math.min(maxItems, inputStack.stackSize);
usedAmount = perItemIncrease * itemsUsed;
amount += usedAmount;
availableAmount -= usedAmount;
toRemove.add(itemsUsed);
}
} else {
if (this.areItemStacksEquivalent(inputStack, stack)) {
itemsUsed = Math.min(maxItems, inputStack.stackSize);
usedAmount = perItemIncrease * itemsUsed;
amount += usedAmount;
availableAmount -= usedAmount;
toRemove.add(itemsUsed);
}
}
}
}
return amount;
int[] toRemoveArray = new int[toRemove.size()];
for (int i = 0; i < toRemove.size(); i++) {
toRemoveArray[i] = toRemove.get(i);
}
return new ModificationInfo(amount, toRemoveArray);
}
/**
@@ -3,27 +3,29 @@ package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ModificationInfo;
public class ModAntiSpider extends ItemModTypeFilter {
String tooltipName;
int max = 4;
String guiType;
public ModAntiSpider(String type, int effect, ItemStack[] items, int[] values) {
super(effect, "ModAntiSpider", items, values);
tooltipName = "\u00a72Bane of Arthropods";
guiType = type;
this.max = 4;
}
@Override
protected boolean canModify(ItemStack tool, ItemStack[] input) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
else return false;
}
@@ -31,7 +33,10 @@ public class ModAntiSpider extends ItemModTypeFilter {
@Override
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
@@ -6,12 +6,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModAttack extends ItemModTypeFilter {
String tooltipName;
int max;
int threshold;
String guiType;
String modifierType;
@@ -22,7 +22,7 @@ public class ModAttack extends ItemModTypeFilter {
super(effect, "ModAttack", items, value);
tooltipName = "\u00a7fSharpness";
guiType = type;
max = 72;
this.max = 72;
threshold = 24;
modifierType = "Tool";
ammoOnly = false;
@@ -33,7 +33,7 @@ public class ModAttack extends ItemModTypeFilter {
super(effect, "ModAttack", items, value);
tooltipName = "\u00a7fSharpness";
guiType = type;
max = 48;
this.max = 48;
threshold = 24;
modifierType = "Tool";
this.ammoOnly = ammoOnly;
@@ -61,13 +61,14 @@ public class ModAttack extends ItemModTypeFilter {
IModifyable toolItem = (IModifyable) tool.getItem();
if (!validType(toolItem)) return false;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
}
return false;
@@ -83,9 +84,13 @@ public class ModAttack extends ItemModTypeFilter {
public void modify(ItemStack[] input, ItemStack tool) {
IModifyable toolItem = (IModifyable) tool.getItem();
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
int increase = matchingAmount(input);
int overThreshold = increase / threshold;
int leftToBoost = threshold - (keyPair[0] % threshold);
@@ -113,7 +118,6 @@ public class ModAttack extends ItemModTypeFilter {
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
int increase = matchingAmount(input);
int overThreshold = increase / threshold;
String modName = "\u00a7f" + guiType + " (" + increase + "/" + max + ")";
int tooltipIndex = addToolTip(tool, tooltipName, modName);
@@ -6,17 +6,17 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModBlaze extends ItemModTypeFilter {
String tooltipName;
int max;
public ModBlaze(int effect, ItemStack[] items, int[] values) {
super(effect, "Blaze", items, values);
tooltipName = "\u00a76Fiery";
max = 25;
this.max = 25;
}
@Override
@@ -25,13 +25,14 @@ public class ModBlaze extends ItemModTypeFilter {
ToolCore toolItem = (ToolCore) tool.getItem();
if (!validType(toolItem)) return false;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
}
return false;
@@ -40,7 +41,10 @@ public class ModBlaze extends ItemModTypeFilter {
@Override
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] % max == 0) {
@@ -11,16 +11,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModLapis extends ItemModTypeFilter {
String tooltipName;
int max = 450;
public ModLapis(int effect, ItemStack[] items, int[] values) {
super(effect, "Lapis", items, values);
tooltipName = "\u00a79Luck";
this.max = 450;
}
@Override
@@ -29,16 +30,17 @@ public class ModLapis extends ItemModTypeFilter {
ToolCore toolItem = (ToolCore) tool.getItem();
if (!validType(toolItem)) return false;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Silk Touch")) return false;
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
return keyPair[0] + matchingAmount(input) <= max;
return keyPair[0] + matchingAmount(input, tool).total() <= max;
}
return false;
}
@@ -59,7 +61,10 @@ public class ModLapis extends ItemModTypeFilter {
tags.setInteger("Modifiers", modifiers);
}
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool, 450);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
int[] keyPair = tags.getIntArray(key);
keyPair[0] += increase;
tags.setIntArray(key, keyPair);
@@ -6,16 +6,17 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModPiston extends ItemModTypeFilter {
String tooltipName;
int max = 10;
public ModPiston(int effect, ItemStack[] items, int[] values) {
super(effect, "Piston", items, values);
tooltipName = "\u00a77Knockback";
this.max = 10;
}
@Override
@@ -24,13 +25,14 @@ public class ModPiston extends ItemModTypeFilter {
ToolCore toolItem = (ToolCore) tool.getItem();
if (!validType(toolItem)) return false;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
}
return false;
@@ -39,7 +41,10 @@ public class ModPiston extends ItemModTypeFilter {
@Override
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] % max == 0) {
@@ -8,16 +8,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModRedstone extends ItemModTypeFilter {
public String tooltipName;
public int max = 50;
public ModRedstone(int effect, ItemStack[] items, int[] values) {
super(effect, "Redstone", items, values);
tooltipName = "\u00a74Haste";
this.max = 50;
}
@Override
@@ -26,14 +27,15 @@ public class ModRedstone extends ItemModTypeFilter {
ToolCore toolItem = (ToolCore) tool.getItem();
if (!validType(toolItem)) return false;
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
}
@@ -44,7 +46,10 @@ public class ModRedstone extends ItemModTypeFilter {
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int[] keyPair;
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
int current;
if (tags.hasKey(key)) {
keyPair = tags.getIntArray(key);
@@ -3,27 +3,29 @@ package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ModificationInfo;
public class ModSmite extends ItemModTypeFilter {
String tooltipName;
int max = 36;
String tagName;
public ModSmite(String type, int effect, ItemStack[] items, int[] values) {
super(effect, "ModSmite", items, values);
tooltipName = "\u00a7eSmite";
tagName = type;
this.max = 36;
}
@Override
protected boolean canModify(ItemStack tool, ItemStack[] input) {
if (matchingAmount(input) > max) return false;
if (matchingAmount(input, tool).total() > max) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
if (!tags.hasKey(key)) return tags.getInteger("Modifiers") > 0 && matchingAmount(input, tool).total() <= max;
int[] keyPair = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= keyPair[1]) return true;
if (keyPair[0] + matchingAmount(input, tool).total() <= keyPair[1]) return true;
else if (keyPair[0] == keyPair[1]) return tags.getInteger("Modifiers") > 0;
else return false;
}
@@ -31,7 +33,10 @@ public class ModSmite extends ItemModTypeFilter {
@Override
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
if (tags.hasKey(key)) {
int[] keyPair = tags.getIntArray(key);
@@ -6,6 +6,7 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.ModificationInfo;
import tconstruct.library.tools.ToolCore;
public class ModWindup extends ModRedstone {
@@ -31,7 +32,10 @@ public class ModWindup extends ModRedstone {
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
int[] keyPair;
int increase = matchingAmount(input);
ModificationInfo modificationInfo = matchingAmount(input, tool);
int increase = modificationInfo.total();
tags.setIntArray("ToRemove", modificationInfo.toRemove());
int current;
if (tags.hasKey(key)) {
keyPair = tags.getIntArray(key);
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.tools.AbilityHelper;
@@ -23,7 +24,28 @@ public class SlotCraftingStation extends SlotCrafting {
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
ItemStack tool = this.matrix.getStackInSlot(4);
if (stack.getItem() instanceof IModifyable && tool != null && tool.getItem() instanceof IModifyable) {
if (stack.getItem() instanceof IModifyable modifyable && tool != null
&& tool.getItem() instanceof IModifyable) {
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(modifyable.getBaseTagName());
int[] toRemoveArray = tags.hasKey("ToRemove") ? tags.getIntArray("ToRemove") : null;
int toRemoveIndex = 0;
IInventory inventory = this.matrix;
for (int i = 0; i <= inventory.getSizeInventory(); i++) {
if (i == 4) continue;
ItemStack item = inventory.getStackInSlot(i);
if (item == null) {
continue;
}
if (toRemoveArray == null) {
inventory.decrStackSize(i, 1);
} else {
inventory.decrStackSize(i, toRemoveArray[toRemoveIndex]);
toRemoveIndex++;
}
}
tags.removeTag("ToRemove");
matrix.setInventorySlotContents(4, null);
player.worldObj.playSoundEffect(
player.posX,
@@ -32,7 +54,8 @@ public class SlotCraftingStation extends SlotCrafting {
"tinker:little_saw",
1.0F,
(AbilityHelper.random.nextFloat() - AbilityHelper.random.nextFloat()) * 0.2F + 1.0F);
} else {
super.onPickupFromSlot(player, stack);
}
super.onPickupFromSlot(player, stack);
}
}
@@ -55,8 +55,23 @@ public class SlotTool extends Slot {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags = stack.getTagCompound()
.getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
int[] toRemoveArray = tags.hasKey("ToRemove") ? tags.getIntArray("ToRemove") : null;
int toRemoveIndex = 0;
boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null);
for (int i = 2; i <= 3; i++) inventory.decrStackSize(i, 1);
for (int i = 2; i <= 3; i++) {
ItemStack item = inventory.getStackInSlot(i);
if (item == null) {
continue;
}
if (toRemoveArray == null) {
inventory.decrStackSize(i, 1);
} else {
inventory.decrStackSize(i, toRemoveArray[toRemoveIndex]);
toRemoveIndex++;
}
}
tags.removeTag("ToRemove");
ItemStack compare = inventory.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
inventory.decrStackSize(1, amount);
@@ -25,9 +25,25 @@ public class SlotToolForge extends SlotTool {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags = stack.getTagCompound()
.getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
int[] toRemoveArray = tags.hasKey("ToRemove") ? tags.getIntArray("ToRemove") : null;
int toRemoveIndex = 0;
boolean full = (inventory.getStackInSlot(2) != null || inventory.getStackInSlot(3) != null
|| inventory.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++) inventory.decrStackSize(i, 1);
for (int i = 2; i <= 4; i++) {
ItemStack item = inventory.getStackInSlot(i);
if (item == null) {
continue;
}
if (toRemoveArray == null) {
inventory.decrStackSize(i, 1);
} else {
inventory.decrStackSize(i, toRemoveArray[toRemoveIndex]);
toRemoveIndex++;
}
}
tags.removeTag("ToRemove");
ItemStack compare = inventory.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
inventory.decrStackSize(1, amount);
@@ -74,9 +74,23 @@ public class ToolForgeContainer extends ToolStationContainer {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags = stack.getTagCompound()
.getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
int[] toRemoveArray = tags.hasKey("ToRemove") ? tags.getIntArray("ToRemove") : null;
int toRemoveIndex = 0;
boolean full = (logic.getStackInSlot(2) != null || logic.getStackInSlot(3) != null
|| logic.getStackInSlot(4) != null);
for (int i = 2; i <= 4; i++) logic.decrStackSize(i, 1);
for (int i = 2; i <= 4; i++) {
ItemStack item = logic.getStackInSlot(i);
if (item == null) {
continue;
}
if (toRemoveArray == null) {
logic.decrStackSize(i, 1);
} else {
logic.decrStackSize(i, toRemoveArray[toRemoveIndex]);
toRemoveIndex++;
}
}
ItemStack compare = logic.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
logic.decrStackSize(1, amount);
@@ -124,8 +124,23 @@ public class ToolStationContainer extends ActiveContainer {
if (stack.getItem() instanceof IModifyable) {
NBTTagCompound tags = stack.getTagCompound()
.getCompoundTag(((IModifyable) stack.getItem()).getBaseTagName());
int[] toRemoveArray = tags.hasKey("ToRemove") ? tags.getIntArray("ToRemove") : null;
int toRemoveIndex = 0;
boolean full = (logic.getStackInSlot(2) != null || logic.getStackInSlot(3) != null);
for (int i = 2; i <= 3; i++) logic.decrStackSize(i, 1);
for (int i = 2; i <= 3; i++) {
ItemStack item = logic.getStackInSlot(i);
if (item == null) {
continue;
}
if (toRemoveArray == null) {
logic.decrStackSize(i, 1);
} else {
logic.decrStackSize(i, toRemoveArray[toRemoveIndex]);
toRemoveIndex++;
}
}
tags.removeTag("ToRemove");
ItemStack compare = logic.getStackInSlot(1);
int amount = compare.getItem() instanceof IModifyable ? compare.stackSize : 1;
logic.decrStackSize(1, amount);