3

Can someone make a data pack like this mod?

eithli's Avatar eithli3/18/23 2:00 pm
3 emeralds 249 5
3/22/2023 10:52 pm
eithli's Avatar eithli
Just looking to see if it's possible--or if someone had already made one--to make a data pack that behaves similarly to this mod right here: https://www.curseforge.com/minecraft/mc-mods/short-stacks

The mod has been abandoned as far as I can assume, and I was looking for something that limits the food stack size based on nutrition but couldn't find any. If someone wants to make a data pack like this or can lmk if someone already had then it would be much appreciated.
Posted by eithli's Avatar
eithli
Level 15 : Journeyman Miner
2

Create an account or sign in to comment.

5

2
03/20/2023 6:16 pm
Level 43 : Master Engineer
AmericanBagel
AmericanBagel's Avatar
Possible but difficult -- as is the cast with most things data pack. We obviously can't change the game's code, so just limiting the stack size isn't an option. What this would involve is checking, every tick (1/20 of a second, the refresh rate of minecraft servers) if a player has x food item by checking for EACH slot. That's 37 slots (4 rows and 9 columns with the offhand/shield slot = 4*9+1) that have to be checked every game tick if the player's inventory is full. The Count nbt tag for each slot with an item for each filled (non-empty) slot must be assigned to a scoreboard so we can check if it's over x stack size. If x item is over x stack size in x slot, we'd have to give the player that same item but in another slot, so /give (the easiest option) is out of the question. That just leaves directly assigning the item -- perhaps by putting the nbt data of the item into storage and then retrieving the storage with a modular `place_in_available_slot.mcfunction` function -- directly to the lowest available slot. This obviously wouldn't be perfect, and I'm sure this could leave, if not implemented very carefully, to bugs that either allow item duplication or delete items.

TL;DR without the technical mumbo jumbo: For each players' non-empty slots (slots with items in them):
  • Store the item count of the slot (each slot) to a number
  • Check if the number exceeds x amount (should be assigned to a scoreboard for in-game configuration)
If it does exceed x amount:
  • Subtract current stack count (e.g. 17) to max stack size (e.g. 16) to get the amount of items we need to "refund" the player -- the amount of items that exceeded the stack size.
  • Find the lowest non-empty slot and place that item into the player's inventory with the Count being the amount of items to be refunded.
  • Profit


What this would look like in-game: You have 16 Steak in the first slot of your hotbar. You shift-click 3 Steak from your furnace into your hotbar. For 1/20th of a second (more if your ping is low or the server is lagging), you have 19 Steak in the first slot of your hotbar. The next 1/20th of a second, you have in your first slot 16 Steak and in your second slot 3 Steak. This short "visual glitch" (not actually a glitch, just the game doing what it's intended to do and the data pack fiddling with that) would happen every time a slot that has reached its artificial max slot count gets increased, i.e. when you shift-click or pick up an item into an already "full" slot.




LMK if you really need this pack. I can make it, but I only have so much time to spare. I recommend you learn how to make your own data packs. They're not TOOO hard. :^)
2
03/20/2023 8:15 pm
Level 15 : Journeyman Miner
eithli
eithli's Avatar
Oh yes, I definitely would appreciate it if you could make this data pack if that would really be okay with you.
2
03/20/2023 8:40 pm
Level 43 : Master Engineer
AmericanBagel
AmericanBagel's Avatar
I'm working on it right now. Can you let me know the stack sizes of each foods or how the stack size should be determined? You have time to respond. I'm working a "stack-limiter" data pack which is a general utility data pack for limiting stack sizes, so it can be used for stack size limiting in general.
2
03/21/2023 2:15 pm
Level 15 : Journeyman Miner
eithli
eithli's Avatar
Sending this again b/c my comment won't go through but,

"The food stack sizes that I can see on the mod page are as follows.

Steak: 8
Bread: 12
Chicken: 10
Apple: 16
Mutton: 10
Rabbit Stew: 6
Sweet Berry's: 32
Honey Bottles: 10
Pumpkin Pie: 8

Basically, the more hunger filled from a food item, the lower the stack.

For example:
- Steak only stacks up to 8 because it gives 4 food points, whereas sweet berry stacks up to 32 because it only gives 1 food point.
- The highest a food would stack would be 64, which would be the foods that give only half a hunger point (tropical fish, pufferfish, potatoes, beetroots, and any other half-point foods I missed.)

From there, you can probably calculate how other foods would stack & if you want to double-check, you can install the mod I linked and test it yourself. I hope that clears things up!"
2
03/21/2023 7:35 am
Level 61 : High Grandmaster Sweetheart
imalittlhigh
imalittlhigh's Avatar
if u need/want inspiration I made a pack that limits food stack sizes to 1, might give you ideas/input how to do the stack limiting (if you havent already done it ^^)
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome