summaryrefslogtreecommitdiff
path: root/src/main/java/ihl/flexible_cable/InvSlotTool.java
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-08-10 18:52:45 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-08-10 18:52:45 +0300
commit0427ab89f1753a44b30cbc35ce021cbbdc845109 (patch)
treeabe418ff5ec174e712fe8dedd434548a945b15a3 /src/main/java/ihl/flexible_cable/InvSlotTool.java
parent877312184c472d9845e5ef1008bc538f4634059f (diff)
fix missing source folder
Diffstat (limited to 'src/main/java/ihl/flexible_cable/InvSlotTool.java')
-rw-r--r--src/main/java/ihl/flexible_cable/InvSlotTool.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/ihl/flexible_cable/InvSlotTool.java b/src/main/java/ihl/flexible_cable/InvSlotTool.java
new file mode 100644
index 0000000..0d5119e
--- /dev/null
+++ b/src/main/java/ihl/flexible_cable/InvSlotTool.java
@@ -0,0 +1,69 @@
+package ihl.flexible_cable;
+
+import java.util.Iterator;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.IC2;
+import ihl.recipes.IronWorkbenchRecipe;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class InvSlotTool extends IronWorkbenchInvSlot {
+
+ public InvSlotTool(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, Access access1, int count) {
+ super(base1, name1, oldStartIndex1, access1, count);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void damage(List<IRecipeInput> tools) {
+ if (tools != null && !tools.isEmpty()) {
+ for (int i = 0; i < this.size(); i++) {
+ ItemStack is = this.get(i);
+ Iterator<IRecipeInput> i1 = tools.iterator();
+ while (i1.hasNext()) {
+ IRecipeInput is1 = i1.next();
+ if (is != null && (is1.matches(is))) {
+ if (!is.attemptDamageItem(1, IC2.random)) {
+ if (is.stackTagCompound != null && is.stackTagCompound.hasKey("GT.ToolStats")) {
+ IHLUtils.damageItemViaNBTTag(is, 1);
+ }
+ }
+ if (is.stackSize <= 0) {
+ this.put(i, null);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void put(int index, ItemStack content) {
+ super.put(index, content);
+ if (IC2.platform.isSimulating() && ((IronWorkbenchTileEntity) this.base).container != null) {
+ ((IronWorkbenchTileEntity) this.base).resetOutput();
+ ((IronWorkbenchTileEntity) this.base).container.detectAndSendChanges();
+ }
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack) {
+ for (IronWorkbenchRecipe recipe : IronWorkbenchTileEntity.recipes) {
+ if (recipe.isTool(itemStack)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean contain(ItemStack is1) {
+ for (int i = 0; i < this.size(); i++) {
+ ItemStack is = this.get(i);
+ if (is != null && (is.getItem() == is1.getItem() || IHLUtils.isItemsHaveSameOreDictionaryEntry(is, is1))) {
+ return true;
+ }
+ }
+ return false;
+ }
+}