KrisCris/AllStackable

Make auto-spliting on item damages optional (tools/weapons/etc.)

Closed this issue ยท 16 comments

it's just when u want to equip more than 1 armor it don't let to do , it allways equip only one (but u can equip shields fine)

lol tested if u somehow manage to equip more than 1 armor in one slot it unequip them if it got damaged (one will stay "in you" and the others got send back to ur inv) sadly it also work with shield

lol if u have something in ur hand (more than 1) and it got dmg (lost durability) it got unstacked so u will have 1 in ur hand and the rest in ur inv

ofc if ur inv is full , u will have only one of that thing and the rest will be dropped on the ground

lol if u have something in ur hand (more than 1) and it got dmg (lost durability) it got unstacked so u will have 1 in ur hand and the rest in ur inv

ofc if ur inv is full , u will have only one of that thing and the rest will be dropped on the ground

I think that's the intended behavior, I made it do that.

Whereas without my fixes, all damageable items just got the same dmg lol

@Redirect(method = "damage(ILnet/minecraft/util/math/random/Random;Lnet/minecraft/server/network/ServerPlayerEntity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setDamage(I)V"))
private void splitStackedTools(ItemStack stack, int damage, int amount, Random random, @Nullable ServerPlayerEntity player){
ItemStack rest = null;
if (stack.getCount()>1 && ItemsHelper.isModified(stack) && player!=null){
rest = stack.copy();
rest.decrement(1);
stack.setCount(1);
}
stack.setDamage(damage);
if (rest != null){
ItemsHelper.insertNewItem(player,rest);
}
}
}

I honestly can't come up with a better solution. So this probably won't be fixed as this is not a bug.

in vanilla mc if u obtain stacked armors/tools it's cool bc if u break it u will get all the rest with full durability i mean the durability resets so this is useless :(

@Redirect(method = "damage(ILnet/minecraft/util/math/random/Random;Lnet/minecraft/server/network/ServerPlayerEntity;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setDamage(I)V"))
private void splitStackedTools(ItemStack stack, int damage, int amount, Random random, @Nullable ServerPlayerEntity player){
ItemStack rest = null;
if (stack.getCount()>1 && ItemsHelper.isModified(stack) && player!=null){
rest = stack.copy();
rest.decrement(1);
stack.setCount(1);
}
stack.setDamage(damage);
if (rest != null){
ItemsHelper.insertNewItem(player,rest);
}
}
}

I honestly can't come up with a better solution. So this probably won't be fixed as this is not a bug.

it wouls be cool if u would make it to togle-able or something like that

hmm what do you mean? when you are using a stack of tools/shields/weapons, only one of them will get damaged.

by disable that code, not just one, ALL stack of them lose durability

by disable that code, not just one, ALL stack of them lose durability

yes ... but if u manage to break that item one will be loosen

yes ... but if u manage to break that item one will be loosen

you mean the damaged item will be unstacked, right?

I don't think a stack of items can have different states, like one with full durability while the rest are broken or something

i try-ed with leather armor and gold tools if u have
64 gold pickaxe (in stack) and u break 32 block with it u will have 63 gold pickaxe (in stack) and the one is broken (bc gold tools have 32 durability)
and if u have 64 leather cap in ur helmet slot and it got 55 damage (the leather cap durability) u will have 63 leather cap in ur armor slot

yes if u manually unstack them before one break all will have the durability loss but i don't want that so i wait untill it gets breaked

lol i see... the game resets the durability of the rest of the stacks to full when one item is broken... so if you have 2 damaged item happens to have the same durability, and you stack them together, broke one, another one get full durability

anyway... if you prefer this way...
there you go AllStackable-v1.5.6-1.19.zip
make sure you have "noAutoUnstackDamageableTools": 1 in your config, something like the following:

[
    {
        "minecraft:golden_axe": 16
    },
    {
        "permissionLevel": 4,
        "stackEmptyShulkerBoxOnly": 0,
        "noAutoUnstackDamageableTools": 1
    }
]

lol i see... the game resets the durability of the rest of the stacks to full when one item is broken... so if you have 2 damaged item happens to have the same durability, and you stack them together, broke one, another one get full durability

so yeah, i will not fix the reset issue as the game has no idea what's the durability of the rest of the stack lol