Added functional iron upgrade

This commit is contained in:
Buuz135 2021-12-22 20:42:26 +01:00
parent e15e6eba9d
commit c18a62b2e8
8 changed files with 49 additions and 16 deletions

View File

@ -25,7 +25,7 @@ a0ff8d6c8f3d10d7773039df53dd3b6a5412bc10 assets/functionalstorage/blockstates/sp
e27f738dc4aeda4f45831ab1665a7f44a189a6eb assets/functionalstorage/blockstates/warped_1.json
d219b51e15094f26af1f2e1c4578707c74a8892e assets/functionalstorage/blockstates/warped_2.json
9957ebb8beafe7cfa8634e1b19c3b9ed70a23ae5 assets/functionalstorage/blockstates/warped_4.json
93d67cc8bfa87e012c9d97f4b275234c91c3b170 assets/functionalstorage/lang/en_us.json
9dd6f6257a11b65464b17d9ee2fd5502afe13548 assets/functionalstorage/lang/en_us.json
f9c11e430cfeef0c24c5b10b7e6bdff04d5efa6a assets/functionalstorage/models/item/collector_upgrade.json
eed1ee36f7bc9269b2e0300a89c1418ac3cf8a29 assets/functionalstorage/models/item/copper_upgrade.json
06a823abd508e43d00013698b1b65eb1f71feecf assets/functionalstorage/models/item/diamond_upgrade.json
@ -87,4 +87,4 @@ ff234dac4f0b0b4f83ffa92f2d2fb1074c68df43 data/functionalstorage/recipes/spruce_4
bcb281904eac23183c45786e3d703d24bba92be6 data/functionalstorage/recipes/warped_1.json
8fc3f76a2c57eb4d80ce86947fabebe48fa6f692 data/functionalstorage/recipes/warped_2.json
7510a8ca1f1e3bb63f4c4f4add0bb6b713feaa0b data/functionalstorage/recipes/warped_4.json
d02963f7da0ca8877113c80cb1dd49d60069ff78 data/functionalstorage/tags/items/drawer.json
f37e620a26ceb158507c607cee6ba3b51f14c6d6 data/functionalstorage/tags/items/drawer.json

View File

@ -38,6 +38,7 @@
"item.functionalstorage.void_upgrade": "Void Upgrade",
"item.utility.direction": "Direction: ",
"item.utility.direction.desc": "Right click in a GUI to change direction",
"item.utility.downgrade": "Downgrades the slots to a max of 64 items",
"itemGroup.functionalstorage": "Functional Storage",
"key.categories.storage": "Storage",
"key.categories.utility": "Utility",

View File

@ -1,14 +1,6 @@
{
"replace": false,
"values": [
"functionalstorage:oak_4",
"functionalstorage:spruce_4",
"functionalstorage:birch_4",
"functionalstorage:jungle_4",
"functionalstorage:acacia_4",
"functionalstorage:dark_oak_4",
"functionalstorage:crimson_4",
"functionalstorage:warped_4",
"functionalstorage:oak_2",
"functionalstorage:spruce_2",
"functionalstorage:birch_2",
@ -17,6 +9,14 @@
"functionalstorage:dark_oak_2",
"functionalstorage:crimson_2",
"functionalstorage:warped_2",
"functionalstorage:oak_4",
"functionalstorage:spruce_4",
"functionalstorage:birch_4",
"functionalstorage:jungle_4",
"functionalstorage:acacia_4",
"functionalstorage:dark_oak_4",
"functionalstorage:crimson_4",
"functionalstorage:warped_4",
"functionalstorage:oak_1",
"functionalstorage:spruce_1",
"functionalstorage:birch_1",

View File

@ -34,19 +34,18 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
private static HashMap<UUID, Long> INTERACTION_LOGGER = new HashMap<>();
//TODO Lock the slots for the upgrades
//TODO Add support for the iron upgrade
@Save
private BlockPos controllerPos;
@Save
private InventoryComponent<ControllableDrawerTile<T>> storageUpgrades;
@Save
private InventoryComponent<ControllableDrawerTile<T>> utilityUpgrades;
@Save
private boolean locked;
public ControllableDrawerTile(BasicTileBlock<T> base, BlockPos pos, BlockState state) {
super(base, pos, state);
this.locked = false;
this.addInventory((InventoryComponent<T>) (this.storageUpgrades = new InventoryComponent<ControllableDrawerTile<T>>("storage_upgrades", 10, 70, getStorageSlotAmount()) {
@NotNull
@Override
@ -70,7 +69,16 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
return super.extractItem(slot, amount, simulate);
}
}
.setInputFilter((stack, integer) -> stack.getItem() instanceof UpgradeItem && ((UpgradeItem) stack.getItem()).getType() == UpgradeItem.Type.STORAGE)
.setInputFilter((stack, integer) -> {
if (stack.getItem().equals(FunctionalStorage.STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.IRON).get())){
for (int i = 0; i < getStorage().getSlots(); i++) {
if (getStorage().getStackInSlot(i).getCount() > 64){
return false;
}
}
}
return stack.getItem() instanceof UpgradeItem && ((UpgradeItem) stack.getItem()).getType() == UpgradeItem.Type.STORAGE;
})
.setSlotLimit(1))
);
this.addInventory((InventoryComponent<T>) (this.utilityUpgrades = new InventoryComponent<ControllableDrawerTile<T>>("utility_upgrades", 114, 70, 3)
@ -174,6 +182,15 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
public abstract int getBaseSize(int lost);
public boolean hasDowngrade(){
for (int i = 0; i < this.storageUpgrades.getSlots(); i++) {
if (storageUpgrades.getStackInSlot(i).getItem().equals(FunctionalStorage.STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.IRON).get())){
return true;
}
}
return false;
}
@Override
public void invalidateCaps() {
super.invalidateCaps();

View File

@ -55,6 +55,13 @@ public class DrawerTile extends ControllableDrawerTile<DrawerTile> {
public boolean isVoid() {
return DrawerTile.this.isVoid();
}
@Override
public boolean hasDowngrade() {
return DrawerTile.this.hasDowngrade();
}
};
lazyStorage = LazyOptional.of(() -> this.handler);
}

View File

@ -48,6 +48,7 @@ public class FunctionalStorageLangProvider extends LanguageProvider {
this.add(FunctionalStorage.PUSHING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PUSHING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.VOID_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.VOID_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.ARMORY_CABINET.get(), "Armory Cabinet");
this.add("item.utility.downgrade", "Downgrades the slots to a max of 64 items");
this.add("item.utility.direction", "Direction: ");
this.add("item.utility.direction.desc", "Right click in a GUI to change direction");
}

View File

@ -90,6 +90,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
@Override
public int getSlotLimit(int slot) {
if (hasDowngrade()) return 64;
return Math.min(Integer.MAX_VALUE, type.getSlotAmount() * getMultiplier());
}
@ -131,6 +132,8 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
public abstract boolean isVoid();
public abstract boolean hasDowngrade();
public class BigStack{
private ItemStack stack;

View File

@ -32,7 +32,11 @@ public class StorageUpgradeItem extends UpgradeItem{
@Override
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
super.addTooltipDetails(key, stack, tooltip, advanced);
tooltip.add(new TranslatableComponent("storageupgrade.desc").withStyle(ChatFormatting.GRAY).append(this.storageTier.getStorageMultiplier() + ""));
if (storageTier == StorageTier.IRON){
tooltip.add(new TranslatableComponent("item.utility.downgrade").withStyle(ChatFormatting.GRAY));
} else {
tooltip.add(new TranslatableComponent("storageupgrade.desc").withStyle(ChatFormatting.GRAY).append(this.storageTier.getStorageMultiplier() + ""));
}
}
@Override