From 34978f7ffe63cd7d7fbd25ff9643064da3523f36 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 11 Apr 2017 00:12:36 +0100 Subject: [PATCH] Remove old upgrade handler to make way for the new one. --- .../java/techreborn/api/gui/SlotUpgrade.java | 4 +- .../ContainerTileInventoryBuilder.java | 4 +- .../java/techreborn/items/ItemUpgrades.java | 41 ++++++------ .../techreborn/tiles/TileAlloySmelter.java | 4 -- .../tiles/teir1/TileCompressor.java | 5 +- .../techreborn/tiles/teir1/TileExtractor.java | 4 -- .../techreborn/tiles/teir1/TileGrinder.java | 4 -- .../utils/upgrade/IMachineUpgrade.java | 33 ---------- .../utils/upgrade/UpgradeHandler.java | 64 ------------------- .../utils/upgrade/package-info.java | 28 -------- 10 files changed, 25 insertions(+), 166 deletions(-) delete mode 100644 src/main/java/techreborn/utils/upgrade/IMachineUpgrade.java delete mode 100644 src/main/java/techreborn/utils/upgrade/UpgradeHandler.java delete mode 100644 src/main/java/techreborn/utils/upgrade/package-info.java diff --git a/src/main/java/techreborn/api/gui/SlotUpgrade.java b/src/main/java/techreborn/api/gui/SlotUpgrade.java index 9b4236d3c..b0ae361ae 100644 --- a/src/main/java/techreborn/api/gui/SlotUpgrade.java +++ b/src/main/java/techreborn/api/gui/SlotUpgrade.java @@ -26,8 +26,8 @@ package techreborn.api.gui; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import reborncore.api.tile.IUpgrade; import reborncore.client.gui.slots.BaseSlot; -import techreborn.utils.upgrade.IMachineUpgrade; public class SlotUpgrade extends BaseSlot { @@ -37,6 +37,6 @@ public class SlotUpgrade extends BaseSlot { @Override public boolean isItemValid(ItemStack stack) { - return stack.getItem() instanceof IMachineUpgrade; + return stack.getItem() instanceof IUpgrade; } } diff --git a/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java index f597a78e8..4211b154c 100644 --- a/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java +++ b/src/main/java/techreborn/client/container/builder/ContainerTileInventoryBuilder.java @@ -37,6 +37,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import reborncore.api.power.IEnergyInterfaceItem; import reborncore.api.recipe.IRecipeCrafterProvider; +import reborncore.api.tile.IUpgrade; import reborncore.client.gui.slots.BaseSlot; import reborncore.client.gui.slots.SlotFake; import reborncore.client.gui.slots.SlotOutput; @@ -44,7 +45,6 @@ import reborncore.common.powerSystem.TilePowerAcceptor; import techreborn.Core; import techreborn.client.container.builder.slot.FilteredSlot; -import techreborn.utils.upgrade.IMachineUpgrade; import java.util.function.Consumer; import java.util.function.IntConsumer; @@ -107,7 +107,7 @@ public class ContainerTileInventoryBuilder { public ContainerTileInventoryBuilder upgradeSlot(final int index, final int x, final int y) { this.parent.slots.add(new FilteredSlot(this.tile, index, x, y) - .setFilter(stack -> stack.getItem() instanceof IMachineUpgrade)); + .setFilter(stack -> stack.getItem() instanceof IUpgrade)); return this; } diff --git a/src/main/java/techreborn/items/ItemUpgrades.java b/src/main/java/techreborn/items/ItemUpgrades.java index 986b12f82..5090f2f42 100644 --- a/src/main/java/techreborn/items/ItemUpgrades.java +++ b/src/main/java/techreborn/items/ItemUpgrades.java @@ -34,12 +34,11 @@ import net.minecraft.util.text.translation.I18n; import reborncore.common.recipes.RecipeCrafter; import techreborn.client.TechRebornCreativeTabMisc; import techreborn.init.ModItems; -import techreborn.utils.upgrade.IMachineUpgrade; import java.security.InvalidParameterException; import java.util.List; -public class ItemUpgrades extends ItemTRNoDestroy implements IMachineUpgrade { +public class ItemUpgrades extends ItemTRNoDestroy { public static final String[] types = new String[] { "overclock", "transformer", "energy_storage", "range" }; @@ -81,25 +80,25 @@ public class ItemUpgrades extends ItemTRNoDestroy implements IMachineUpgrade { } } - @Override - public void processUpgrade(RecipeCrafter crafter, ItemStack stack) { - // Remember the max speed multiplier can only be 0.99!! - - if (stack.getItemDamage() == 0) {// Check the meta data here - crafter.addSpeedMulti(0.2);// This will set the speed multiplier to - // 0.8 - crafter.addPowerMulti(0.5);// This will use eu/tick x 1.5 - // crafter.addPowerMulti(2); This will use twice the amount of - // power. - } - if (stack.getItemDamage() == 1) { - crafter.addPowerMulti(-0.2);// This will use eu/tick 0.8 - } - if (stack.getItemDamage() == 2) { - crafter.addSpeedMulti(0.5); - crafter.addPowerMulti(1); - } - } +// @Override +// public void processUpgrade(RecipeCrafter crafter, ItemStack stack) { +// // Remember the max speed multiplier can only be 0.99!! +// +// if (stack.getItemDamage() == 0) {// Check the meta data here +// crafter.addSpeedMulti(0.2);// This will set the speed multiplier to +// // 0.8 +// crafter.addPowerMulti(0.5);// This will use eu/tick x 1.5 +// // crafter.addPowerMulti(2); This will use twice the amount of +// // power. +// } +// if (stack.getItemDamage() == 1) { +// crafter.addPowerMulti(-0.2);// This will use eu/tick 0.8 +// } +// if (stack.getItemDamage() == 2) { +// crafter.addSpeedMulti(0.5); +// crafter.addPowerMulti(1); +// } +// } @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { diff --git a/src/main/java/techreborn/tiles/TileAlloySmelter.java b/src/main/java/techreborn/tiles/TileAlloySmelter.java index ad1ef3a85..7a9b111a1 100644 --- a/src/main/java/techreborn/tiles/TileAlloySmelter.java +++ b/src/main/java/techreborn/tiles/TileAlloySmelter.java @@ -46,7 +46,6 @@ import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import techreborn.utils.upgrade.UpgradeHandler; public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider { @@ -55,7 +54,6 @@ public class TileAlloySmelter extends TilePowerAcceptor public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64, this); public RecipeCrafter crafter; public int capacity = 1000; - UpgradeHandler upgrades; public TileAlloySmelter() { super(1); @@ -66,14 +64,12 @@ public class TileAlloySmelter extends TilePowerAcceptor final int[] outputs = new int[1]; outputs[0] = 2; this.crafter = new RecipeCrafter(Reference.alloySmelteRecipe, this, 2, 1, this.inventory, inputs, outputs); - this.upgrades = new UpgradeHandler(this.crafter, this.inventory, 4, 5, 6, 7); } @Override public void update() { super.update(); this.crafter.updateEntity(); - this.upgrades.tick(); this.charge(3); } diff --git a/src/main/java/techreborn/tiles/teir1/TileCompressor.java b/src/main/java/techreborn/tiles/teir1/TileCompressor.java index 3cf066353..cdae469a4 100644 --- a/src/main/java/techreborn/tiles/teir1/TileCompressor.java +++ b/src/main/java/techreborn/tiles/teir1/TileCompressor.java @@ -39,13 +39,11 @@ import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import techreborn.utils.upgrade.UpgradeHandler; public class TileCompressor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileCompressor", 64, this); - public UpgradeHandler upgradeHandler; public RecipeCrafter crafter; public int capacity = 1000; @@ -55,7 +53,7 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II final int[] inputs = new int[] { 0 }; final int[] outputs = new int[] { 1 }; this.crafter = new RecipeCrafter(Reference.compressorRecipe, this, 2, 1, this.inventory, inputs, outputs); - this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 2, 3, 4, 5); + } @Override @@ -63,7 +61,6 @@ public class TileCompressor extends TilePowerAcceptor implements IWrenchable, II if (!this.world.isRemote) { super.update(); this.crafter.updateEntity(); - this.upgradeHandler.tick(); this.charge(3); } } diff --git a/src/main/java/techreborn/tiles/teir1/TileExtractor.java b/src/main/java/techreborn/tiles/teir1/TileExtractor.java index 4e4adbed8..4a3906695 100644 --- a/src/main/java/techreborn/tiles/teir1/TileExtractor.java +++ b/src/main/java/techreborn/tiles/teir1/TileExtractor.java @@ -40,14 +40,12 @@ import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import techreborn.utils.upgrade.UpgradeHandler; public class TileExtractor extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileExtractor", 64, this); - public UpgradeHandler upgradeHandler; public RecipeCrafter crafter; public int capacity = 1000; @@ -59,7 +57,6 @@ public class TileExtractor extends TilePowerAcceptor final int[] outputs = new int[1]; outputs[0] = 1; this.crafter = new RecipeCrafter(Reference.extractorRecipe, this, 2, 1, this.inventory, inputs, outputs); - this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 2, 3, 4, 5); } @Override @@ -67,7 +64,6 @@ public class TileExtractor extends TilePowerAcceptor if (!this.world.isRemote) { super.update(); this.crafter.updateEntity(); - this.upgradeHandler.tick(); this.charge(3); } } diff --git a/src/main/java/techreborn/tiles/teir1/TileGrinder.java b/src/main/java/techreborn/tiles/teir1/TileGrinder.java index d6cef9411..86f13c87a 100644 --- a/src/main/java/techreborn/tiles/teir1/TileGrinder.java +++ b/src/main/java/techreborn/tiles/teir1/TileGrinder.java @@ -42,14 +42,12 @@ import techreborn.client.container.IContainerProvider; import techreborn.client.container.builder.BuiltContainer; import techreborn.client.container.builder.ContainerBuilder; import techreborn.init.ModBlocks; -import techreborn.utils.upgrade.UpgradeHandler; public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider { public Inventory inventory = new Inventory(6, "TileGrinder", 64, this); - public UpgradeHandler upgradeHandler; public RecipeCrafter crafter; public int capacity = 1000; @@ -61,14 +59,12 @@ implements IWrenchable, IInventoryProvider, IRecipeCrafterProvider, IContainerPr final int[] outputs = new int[1]; outputs[0] = 1; this.crafter = new RecipeCrafter(Reference.grinderRecipe, this, 2, 1, this.inventory, inputs, outputs); - this.upgradeHandler = new UpgradeHandler(this.crafter, this.inventory, 2, 3, 4, 5); } @Override public void update() { if (!this.world.isRemote) { super.update(); - this.upgradeHandler.tick(); //charge(3); TODO this.charge(3); } diff --git a/src/main/java/techreborn/utils/upgrade/IMachineUpgrade.java b/src/main/java/techreborn/utils/upgrade/IMachineUpgrade.java deleted file mode 100644 index 5eefb2145..000000000 --- a/src/main/java/techreborn/utils/upgrade/IMachineUpgrade.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2017 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.utils.upgrade; - -import net.minecraft.item.ItemStack; -import reborncore.common.recipes.RecipeCrafter; - -public interface IMachineUpgrade { - - public void processUpgrade(RecipeCrafter crafter, ItemStack stack); -} diff --git a/src/main/java/techreborn/utils/upgrade/UpgradeHandler.java b/src/main/java/techreborn/utils/upgrade/UpgradeHandler.java deleted file mode 100644 index 9f9ede7eb..000000000 --- a/src/main/java/techreborn/utils/upgrade/UpgradeHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2017 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package techreborn.utils.upgrade; - -import net.minecraft.item.ItemStack; -import reborncore.common.recipes.RecipeCrafter; -import reborncore.common.util.Inventory; - -import java.util.ArrayList; - -public class UpgradeHandler { - - RecipeCrafter crafter; - - Inventory inventory; - - ArrayList slots = new ArrayList<>(); - - public UpgradeHandler(RecipeCrafter crafter, Inventory inventory, int... slots) { - this.crafter = crafter; - this.inventory = inventory; - for (int slot : slots) { - this.slots.add(slot); - } - } - - public void tick() { - if (crafter.parentTile.getWorld().isRemote) - return; - crafter.resetPowerMulti(); - crafter.resetSpeedMulti(); - for (int slot : this.slots) { - ItemStack stack = inventory.getStackInSlot(slot); - if (stack != ItemStack.EMPTY && stack.getItem() instanceof IMachineUpgrade) { - ((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack); - } - } - if (crafter.currentRecipe != null) - crafter.currentNeededTicks = (int) (crafter.currentRecipe.tickTime() - * (1.0 - crafter.getSpeedMultiplier())); - } -} diff --git a/src/main/java/techreborn/utils/upgrade/package-info.java b/src/main/java/techreborn/utils/upgrade/package-info.java deleted file mode 100644 index 7065b957f..000000000 --- a/src/main/java/techreborn/utils/upgrade/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of TechReborn, licensed under the MIT License (MIT). - * - * Copyright (c) 2017 TechReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") -package techreborn.utils.upgrade; - -import net.minecraftforge.fml.common.API;