Implemented Unit Upgraders. Thanks to Ayutac.
* Started working on upgraders * debug so game doesn't crash anymore * orientation is saved now * duplication bug removed * added model files, lang entries and recipes+toasts
This commit is contained in:
parent
d339f61d4d
commit
0bcd2bec03
20 changed files with 410 additions and 8 deletions
|
@ -89,6 +89,7 @@ import techreborn.entities.EntityNukePrimed;
|
|||
import techreborn.events.ModRegistry;
|
||||
import techreborn.items.DynamicCellItem;
|
||||
import techreborn.items.UpgradeItem;
|
||||
import techreborn.items.UpgraderItem;
|
||||
import techreborn.items.armor.QuantumSuitItem;
|
||||
import techreborn.utils.InitUtils;
|
||||
import techreborn.world.OreDistribution;
|
||||
|
@ -301,22 +302,23 @@ public class TRContent {
|
|||
}
|
||||
|
||||
public enum StorageUnit implements ItemConvertible {
|
||||
BUFFER(1),
|
||||
CRUDE(TechRebornConfig.crudeStorageUnitMaxStorage),
|
||||
BASIC(TechRebornConfig.basicStorageUnitMaxStorage),
|
||||
ADVANCED(TechRebornConfig.advancedStorageUnitMaxStorage),
|
||||
INDUSTRIAL(TechRebornConfig.industrialStorageUnitMaxStorage),
|
||||
QUANTUM(TechRebornConfig.quantumStorageUnitMaxStorage),
|
||||
CREATIVE(Integer.MAX_VALUE);
|
||||
BUFFER(1, false),
|
||||
CRUDE(TechRebornConfig.crudeStorageUnitMaxStorage, true),
|
||||
BASIC(TechRebornConfig.basicStorageUnitMaxStorage, true),
|
||||
ADVANCED(TechRebornConfig.advancedStorageUnitMaxStorage, true),
|
||||
INDUSTRIAL(TechRebornConfig.industrialStorageUnitMaxStorage, true),
|
||||
QUANTUM(TechRebornConfig.quantumStorageUnitMaxStorage, false),
|
||||
CREATIVE(Integer.MAX_VALUE, false);
|
||||
|
||||
public final String name;
|
||||
public final Block block;
|
||||
public final Item upgrader;
|
||||
|
||||
// How many items it can hold
|
||||
public int capacity;
|
||||
|
||||
|
||||
StorageUnit(int capacity) {
|
||||
StorageUnit(int capacity, boolean upgradable) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
block = new StorageUnitBlock(this);
|
||||
this.capacity = capacity;
|
||||
|
@ -325,12 +327,38 @@ public class TRContent {
|
|||
InitUtils.setup(block, "storage_buffer");
|
||||
else
|
||||
InitUtils.setup(block, name + "_storage_unit");
|
||||
if (upgradable) {
|
||||
if (name.equals("buffer"))
|
||||
upgrader = InitUtils.setup(new UpgraderItem(), "storage_buffer_upgrader");
|
||||
else
|
||||
upgrader = InitUtils.setup(new UpgraderItem(), name + "_unit_upgrader");
|
||||
}
|
||||
else
|
||||
upgrader = null;
|
||||
}
|
||||
|
||||
public Block asBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item asItem() {
|
||||
return block.asItem();
|
||||
}
|
||||
|
||||
public Optional<Item> getUpgrader() {
|
||||
return Optional.ofNullable(upgrader);
|
||||
}
|
||||
|
||||
public static Optional<StorageUnit> getUpgradableFor(UpgraderItem item) {
|
||||
if (item == null)
|
||||
return Optional.empty();
|
||||
for (StorageUnit unit : StorageUnit.values()) {
|
||||
if (item.equals(unit.getUpgrader().orElse(null)))
|
||||
return Optional.of(unit);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public enum TankUnit implements ItemConvertible {
|
||||
|
@ -355,10 +383,33 @@ public class TRContent {
|
|||
InitUtils.setup(block, name + "_tank_unit");
|
||||
}
|
||||
|
||||
public Block asBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item asItem() {
|
||||
return block.asItem();
|
||||
}
|
||||
|
||||
public Optional<Item> getUpgrader() {
|
||||
try {
|
||||
return StorageUnit.valueOf(name()).getUpgrader();
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<TankUnit> getUpgradableFor(UpgraderItem item) {
|
||||
if (item == null)
|
||||
return Optional.empty();
|
||||
for (TankUnit unit : TankUnit.values()) {
|
||||
if (item.equals(unit.getUpgrader().orElse(null)))
|
||||
return Optional.of(unit);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Cables implements ItemConvertible {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue