Upgrades now draw extra energy
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
- Fixed losing autoselection in Grid when clicking on slot with autoselection mode
|
||||
- Added a max crafting quantity per request cap (hardcoded to 100)
|
||||
|
||||
**Features**
|
||||
- Upgrades now draw extra energy
|
||||
|
||||
### 0.6.1
|
||||
**Bugfixes**
|
||||
- Fixed NPE on world load
|
||||
|
||||
@@ -209,10 +209,6 @@ public class RefinedStorageUtils {
|
||||
return getSpeed(inventory, 9, 2, 0);
|
||||
}
|
||||
|
||||
public static int getSpeed(InventorySimple inventory, int start) {
|
||||
return getSpeed(inventory, 9, 2, start);
|
||||
}
|
||||
|
||||
public static int getSpeed(InventorySimple inventory, int speed, int speedIncrease) {
|
||||
return getSpeed(inventory, speed, speedIncrease, 0);
|
||||
}
|
||||
@@ -247,6 +243,22 @@ public class RefinedStorageUtils {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public static int getUpgradeEnergyUsage(InventorySimple inventory) {
|
||||
return getUpgradeEnergyUsage(inventory, 0);
|
||||
}
|
||||
|
||||
public static int getUpgradeEnergyUsage(InventorySimple inventory, int start) {
|
||||
int usage = 0;
|
||||
|
||||
for (int i = start; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
usage += ItemUpgrade.getEnergyUsage(inventory.getStackInSlot(i).getMetadata());
|
||||
}
|
||||
}
|
||||
|
||||
return usage;
|
||||
}
|
||||
|
||||
public static void writeBooleanArray(NBTTagCompound tag, String name, boolean[] array) {
|
||||
int[] intArray = new int[array.length];
|
||||
|
||||
|
||||
@@ -25,4 +25,17 @@ public class ItemUpgrade extends ItemBase {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
public static int getEnergyUsage(int type) {
|
||||
switch (type) {
|
||||
case TYPE_RANGE:
|
||||
return 8;
|
||||
case TYPE_SPEED:
|
||||
return 2;
|
||||
case TYPE_CRAFTING:
|
||||
return 5;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 1;
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,15 +32,12 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 1;
|
||||
return 1 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
// We check if the controller isn't null here because
|
||||
// when a destructor faces a storage network block and removes it
|
||||
// it will essentially remove itself from the network without knowing.
|
||||
if (controller != null && ticks % RefinedStorageUtils.getSpeed(upgradesInventory, BASE_SPEED, 4) == 0) {
|
||||
if (ticks % RefinedStorageUtils.getSpeed(upgradesInventory, BASE_SPEED, 4) == 0) {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
|
||||
IBlockState frontBlockState = worldObj.getBlockState(front);
|
||||
@@ -54,6 +51,9 @@ public class TileDestructor extends TileMachine implements ICompareConfig, IMode
|
||||
worldObj.setBlockToAir(front);
|
||||
|
||||
for (ItemStack drop : drops) {
|
||||
// We check if the controller isn't null here because
|
||||
// when a destructor faces a storage network block and removes it
|
||||
// it will essentially remove this block from the network without knowing.
|
||||
if (controller != null && !controller.push(drop)) {
|
||||
RefinedStorageUtils.dropStack(worldObj, drop, front.getX(), front.getY(), front.getZ());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2;
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TileImporter extends TileMachine implements ICompareConfig, IModeCo
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2;
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 4;
|
||||
return 4 + RefinedStorageUtils.getUpgradeEnergyUsage(upgradesInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,16 +8,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
|
||||
public class TileWirelessTransmitter extends TileMachine implements IInventory {
|
||||
public static final int RANGE_PER_UPGRADE = 8;
|
||||
public static final int RF_PER_UPGRADE = 8;
|
||||
|
||||
private InventorySimple inventory = new InventorySimple("upgrades", 4, this);
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 8 + (getUpgrades() * RF_PER_UPGRADE);
|
||||
return 8 + RefinedStorageUtils.getUpgradeEnergyUsage(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,19 +39,7 @@ public class TileWirelessTransmitter extends TileMachine implements IInventory {
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
return 16 + (getUpgrades() * RANGE_PER_UPGRADE);
|
||||
}
|
||||
|
||||
private int getUpgrades() {
|
||||
int upgrades = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
upgrades++;
|
||||
}
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
return 16 + (RefinedStorageUtils.getUpgradeCount(inventory, ItemUpgrade.TYPE_RANGE) * RANGE_PER_UPGRADE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.container.ContainerCrafter;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
import refinedstorage.tile.autocrafting.task.ICraftingTask;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class TileCrafter extends TileMachine implements IInventory {
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2;
|
||||
return 2 + RefinedStorageUtils.getUpgradeEnergyUsage(inventory, PATTERN_SLOTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,19 +59,7 @@ public class TileCrafter extends TileMachine implements IInventory {
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return 20 - (getUpgrades() * 4);
|
||||
}
|
||||
|
||||
private int getUpgrades() {
|
||||
int upgrades = 0;
|
||||
|
||||
for (int i = PATTERN_SLOTS; i < PATTERN_SLOTS + 4; ++i) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
upgrades++;
|
||||
}
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
return 20 - (RefinedStorageUtils.getUpgradeCount(inventory, ItemUpgrade.TYPE_SPEED, PATTERN_SLOTS) * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user