diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index e78ae22..0fec225 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -24,7 +24,16 @@ 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 -9659c4f1025e1eeab4769a982ac3853e3ebc002b assets/functionalstorage/lang/en_us.json +eeb3ec65b016571323ecfe906a1b1d71300dfdb6 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 +0619620911ab7512e57a491beef71dc68769ba3b assets/functionalstorage/models/item/gold_upgrade.json +d9f1bebe92b59f71359f39dc3441135989fde037 assets/functionalstorage/models/item/iron_downgrade.json +f768a7b0a4e49703c36318bd3da300640caaa295 assets/functionalstorage/models/item/netherite_upgrade.json +443379309025696b7608536277f33a6c444fa525 assets/functionalstorage/models/item/puller_upgrade.json +60e26c140ec529fd49941639b8070de56a1a18c0 assets/functionalstorage/models/item/pusher_upgrade.json +818d0ccc8149687691b50d24c7ee2170c1576024 assets/functionalstorage/models/item/void_upgrade.json 6414c7bf11830af3646da15cb16e601930f785bd data/functionalstorage/loot_tables/blocks/acacia_1.json f0235fd68df6fd2797155af3d56fbe57bef2f0b0 data/functionalstorage/loot_tables/blocks/acacia_2.json db076fb77db0c54a6c9f45307d8c173bf87fb7a9 data/functionalstorage/loot_tables/blocks/acacia_4.json @@ -76,4 +85,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 -db0122948639b122cb0c1df7530996e9784356b0 data/functionalstorage/tags/items/drawer.json +d02963f7da0ca8877113c80cb1dd49d60069ff78 data/functionalstorage/tags/items/drawer.json diff --git a/src/generated/resources/assets/functionalstorage/lang/en_us.json b/src/generated/resources/assets/functionalstorage/lang/en_us.json index c43a257..6ec3406 100644 --- a/src/generated/resources/assets/functionalstorage/lang/en_us.json +++ b/src/generated/resources/assets/functionalstorage/lang/en_us.json @@ -25,7 +25,16 @@ "block.functionalstorage.warped_1": "Warped Drawer (1x1)", "block.functionalstorage.warped_2": "Warped Drawer (2x2)", "block.functionalstorage.warped_4": "Warped Drawer (4x4)", + "item.functionalstorage.collector_upgrade": "Collector Upgrade", + "item.functionalstorage.copper_upgrade": "Copper Upgrade", + "item.functionalstorage.diamond_upgrade": "Diamond Upgrade", + "item.functionalstorage.gold_upgrade": "Gold Upgrade", + "item.functionalstorage.iron_downgrade": "Iron Downgrade", "item.functionalstorage.linking_tool": "Linking Tool", + "item.functionalstorage.netherite_upgrade": "Netherite Upgrade", + "item.functionalstorage.puller_upgrade": "Puller Upgrade", + "item.functionalstorage.pusher_upgrade": "Pusher Upgrade", + "item.functionalstorage.void_upgrade": "Void Upgrade", "itemGroup.functionalstorage": "Functional Storage", "linkingtool.controller": "Controller: ", "linkingtool.linkingaction": "Linking Action: ", @@ -36,5 +45,6 @@ "linkingtool.linkingmode.multiple.desc": "Links multiple drawers between 2 points", "linkingtool.linkingmode.single": "Single", "linkingtool.linkingmode.single.desc": "Links a drawer to a controller", - "linkingtool.use": "Sneak + Right Click in the air to change modes. Right Click in the air to change actions. Right click a controller to setup the tool then use it nearby drawers to link." + "linkingtool.use": "Sneak + Right Click in the air to change modes. Right Click in the air to change actions. Right click a controller to setup the tool then use it nearby drawers to link.", + "storageupgrade.desc": "Multiplies the block storage by " } \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/collector_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/collector_upgrade.json new file mode 100644 index 0000000..e519a26 --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/collector_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/collector_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/copper_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/copper_upgrade.json new file mode 100644 index 0000000..f1bcd6c --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/copper_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/copper_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/diamond_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/diamond_upgrade.json new file mode 100644 index 0000000..35fda0a --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/diamond_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/diamond_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/gold_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/gold_upgrade.json new file mode 100644 index 0000000..7bb2cfa --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/gold_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/gold_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/iron_downgrade.json b/src/generated/resources/assets/functionalstorage/models/item/iron_downgrade.json new file mode 100644 index 0000000..873710f --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/iron_downgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/iron_downgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/netherite_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/netherite_upgrade.json new file mode 100644 index 0000000..a19521a --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/netherite_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/netherite_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/puller_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/puller_upgrade.json new file mode 100644 index 0000000..a1d9a70 --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/puller_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/puller_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/pusher_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/pusher_upgrade.json new file mode 100644 index 0000000..b7596f2 --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/pusher_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/pusher_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/functionalstorage/models/item/void_upgrade.json b/src/generated/resources/assets/functionalstorage/models/item/void_upgrade.json new file mode 100644 index 0000000..41bacdf --- /dev/null +++ b/src/generated/resources/assets/functionalstorage/models/item/void_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "functionalstorage:items/void_upgrade" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/tags/items/drawer.json b/src/generated/resources/data/functionalstorage/tags/items/drawer.json index 6dff867..15ef931 100644 --- a/src/generated/resources/data/functionalstorage/tags/items/drawer.json +++ b/src/generated/resources/data/functionalstorage/tags/items/drawer.json @@ -1,14 +1,6 @@ { "replace": false, "values": [ - "functionalstorage:oak_1", - "functionalstorage:spruce_1", - "functionalstorage:birch_1", - "functionalstorage:jungle_1", - "functionalstorage:acacia_1", - "functionalstorage:dark_oak_1", - "functionalstorage:crimson_1", - "functionalstorage:warped_1", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", @@ -24,6 +16,14 @@ "functionalstorage:acacia_2", "functionalstorage:dark_oak_2", "functionalstorage:crimson_2", - "functionalstorage:warped_2" + "functionalstorage:warped_2", + "functionalstorage:oak_1", + "functionalstorage:spruce_1", + "functionalstorage:birch_1", + "functionalstorage:jungle_1", + "functionalstorage:acacia_1", + "functionalstorage:dark_oak_1", + "functionalstorage:crimson_1", + "functionalstorage:warped_1" ] } \ No newline at end of file diff --git a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java index d4b2696..212daf5 100644 --- a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java +++ b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java @@ -9,6 +9,8 @@ import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider; import com.buuz135.functionalstorage.data.FunctionalStorageLangProvider; import com.buuz135.functionalstorage.data.FunctionalStorageTagsProvider; import com.buuz135.functionalstorage.item.LinkingToolItem; +import com.buuz135.functionalstorage.item.StorageUpgradeItem; +import com.buuz135.functionalstorage.item.UpgradeItem; import com.buuz135.functionalstorage.util.DrawerWoodType; import com.buuz135.functionalstorage.util.IWoodType; import com.hrznstudio.titanium.block.BasicBlock; @@ -29,6 +31,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.EntityRenderersEvent; +import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.common.util.NonNullLazy; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; @@ -58,6 +61,11 @@ public class FunctionalStorage extends ModuleController { public static RegistryObject DRAWER_CONTROLLER; public static RegistryObject LINKING_TOOL; + public static HashMap> STORAGE_UPGRADES = new HashMap<>(); + public static RegistryObject COLLECTOR_UPGRADE; + public static RegistryObject PULLING_UPGRADE; + public static RegistryObject PUSHING_UPGRADE; + public static RegistryObject VOID_UPGRADE; public static AdvancedTitaniumTab TAB = new AdvancedTitaniumTab("functionalstorage", true); @@ -79,6 +87,13 @@ public class FunctionalStorage extends ModuleController { COMPACTING_DRAWER = getRegistries().register(Block.class, "compacting_drawer", () -> new CompactingDrawerBlock("compacting_drawer")); DRAWER_CONTROLLER = getRegistries().register(Block.class, "storage_controller", DrawerControllerBlock::new); LINKING_TOOL = getRegistries().register(Item.class, "linking_tool", LinkingToolItem::new); + for (StorageUpgradeItem.StorageTier value : StorageUpgradeItem.StorageTier.values()) { + STORAGE_UPGRADES.put(value, getRegistries().register(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"),() -> new StorageUpgradeItem(value))); + } + COLLECTOR_UPGRADE = getRegistries().register(Item.class, "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + PULLING_UPGRADE = getRegistries().register(Item.class, "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + PUSHING_UPGRADE = getRegistries().register(Item.class, "pusher_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); + VOID_UPGRADE = getRegistries().register(Item.class, "void_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY)); } public enum DrawerType{ @@ -137,5 +152,21 @@ public class FunctionalStorage extends ModuleController { }); event.getGenerator().addProvider(new FunctionalStorageTagsProvider(event.getGenerator(),new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper())); event.getGenerator().addProvider(new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us")); + event.getGenerator().addProvider(new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) { + @Override + protected void registerModels() { + for (StorageUpgradeItem.StorageTier storageTier : STORAGE_UPGRADES.keySet()) { + item(STORAGE_UPGRADES.get(storageTier).get()); + } + item(COLLECTOR_UPGRADE.get()); + item(PULLING_UPGRADE.get()); + item(PUSHING_UPGRADE.get()); + item(VOID_UPGRADE.get()); + } + + private void item(Item item){ + singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0" ,new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath())); + } + }); } } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java index 221de0b..0a4e654 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageLangProvider.java @@ -2,6 +2,7 @@ package com.buuz135.functionalstorage.data; import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.block.DrawerBlock; +import com.buuz135.functionalstorage.item.StorageUpgradeItem; import net.minecraft.data.DataGenerator; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.LanguageProvider; @@ -36,5 +37,13 @@ public class FunctionalStorageLangProvider extends LanguageProvider { this.add("linkingtool.linkingaction.remove", "Remove"); this.add(FunctionalStorage.LINKING_TOOL.get(), "Linking Tool"); this.add(FunctionalStorage.DRAWER_CONTROLLER.get(), "Storage Controller"); + this.add("storageupgrade.desc", "Multiplies the block storage by "); + for (StorageUpgradeItem.StorageTier storageTier : FunctionalStorage.STORAGE_UPGRADES.keySet()) { + this.add(FunctionalStorage.STORAGE_UPGRADES.get(storageTier).get(), WordUtils.capitalize(storageTier.name().toLowerCase()) + (storageTier == StorageUpgradeItem.StorageTier.IRON ? " Downgrade" : " Upgrade")); + } + this.add(FunctionalStorage.COLLECTOR_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.COLLECTOR_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); + this.add(FunctionalStorage.PULLING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PULLING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) ); + 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()) ); } } diff --git a/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java b/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java index f291736..072f600 100644 --- a/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java +++ b/src/main/java/com/buuz135/functionalstorage/inventory/BigInventoryHandler.java @@ -50,7 +50,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if (isItemValid(slot, stack)) { BigStack bigStack = this.storedStacks.get(slot); - int inserted = Math.min(type.getSlotAmount() - bigStack.getAmount(), stack.getCount()); + int inserted = Math.min(getSlotLimit(slot) - bigStack.getAmount(), stack.getCount()); if (!simulate){ bigStack.setStack(stack); bigStack.setAmount(Math.min(bigStack.getAmount() + inserted, type.getSlotAmount())); @@ -92,7 +92,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa @Override public int getSlotLimit(int slot) { - return type.getSlotAmount(); + return Math.min(Integer.MAX_VALUE, type.getSlotAmount()); } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/item/StorageUpgradeItem.java b/src/main/java/com/buuz135/functionalstorage/item/StorageUpgradeItem.java new file mode 100644 index 0000000..b29b158 --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/item/StorageUpgradeItem.java @@ -0,0 +1,76 @@ +package com.buuz135.functionalstorage.item; + +import com.hrznstudio.titanium.item.BasicItem; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.List; + +public class StorageUpgradeItem extends UpgradeItem{ + + private final StorageTier storageTier; + + public StorageUpgradeItem(StorageTier tier) { + super(new Properties(), Type.STORAGE); + this.storageTier = tier; + } + + public int getStorageMultiplier() { + return storageTier.storageMultiplier; + } + + public StorageTier getStorageTier() { + return storageTier; + } + + @Override + public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List tooltip, boolean advanced) { + super.addTooltipDetails(key, stack, tooltip, advanced); + tooltip.add(new TranslatableComponent("storageupgrade.desc").withStyle(ChatFormatting.GRAY).append(this.storageTier.getStorageMultiplier() + "")); + } + + @Override + public boolean hasTooltipDetails(@Nullable BasicItem.Key key) { + return key == null; + } + + + @Override + public Component getName(ItemStack p_41458_) { + Component component = super.getName(p_41458_); + if (component instanceof TranslatableComponent){ + ((TranslatableComponent) component).setStyle(Style.EMPTY.withColor(storageTier == StorageTier.NETHERITE && Minecraft.getInstance().level != null ? Color.HSBtoRGB((Minecraft.getInstance().level.getGameTime() % 360) / 360f , 1, 1) : storageTier.getColor())); + } + return component; + } + + public static enum StorageTier{ + COPPER(8, new Color(204,109,81).getRGB()), + GOLD(16, new Color(233,177,21).getRGB()), + DIAMOND(24, new Color(32,197,181).getRGB()), + NETHERITE(32, new Color(49,41,42).getRGB()), + IRON(1, new Color(130,130,130).getRGB()); + + private final int storageMultiplier; + private final int color; + + StorageTier(int storageMultiplier, int color) { + this.storageMultiplier = storageMultiplier; + this.color = color; + } + + public int getStorageMultiplier() { + return storageMultiplier; + } + + public int getColor() { + return color; + } + } +} diff --git a/src/main/java/com/buuz135/functionalstorage/item/UpgradeItem.java b/src/main/java/com/buuz135/functionalstorage/item/UpgradeItem.java new file mode 100644 index 0000000..f756d4a --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/item/UpgradeItem.java @@ -0,0 +1,19 @@ +package com.buuz135.functionalstorage.item; + +import com.buuz135.functionalstorage.FunctionalStorage; +import com.hrznstudio.titanium.item.BasicItem; + +public class UpgradeItem extends BasicItem { + + private final Type type; + + public UpgradeItem(Properties properties, Type type) { + super(properties.tab(FunctionalStorage.TAB)); + this.type = type; + } + + public static enum Type{ + STORAGE, + UTILITY + } +}