fixed exception on too many items in a slot
This commit is contained in:
parent
81e45c56ce
commit
17a11ce56a
@ -9,7 +9,7 @@ yarn_mappings=1.21.4+build.1
|
|||||||
loader_version=0.16.9
|
loader_version=0.16.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.21.4.4
|
mod_version=1.21.4.5
|
||||||
maven_group=de.jottyfan.quickiemod
|
maven_group=de.jottyfan.quickiemod
|
||||||
archives_base_name=quickiemod
|
archives_base_name=quickiemod
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import net.minecraft.world.World;
|
|||||||
*/
|
*/
|
||||||
public class ItemHoarderBlockEntity extends LootableContainerBlockEntity {
|
public class ItemHoarderBlockEntity extends LootableContainerBlockEntity {
|
||||||
|
|
||||||
|
|
||||||
private DefaultedList<ItemStack> stacks;
|
private DefaultedList<ItemStack> stacks;
|
||||||
private float suckradius;
|
private float suckradius;
|
||||||
|
|
||||||
@ -44,9 +43,17 @@ public class ItemHoarderBlockEntity extends LootableContainerBlockEntity {
|
|||||||
|
|
||||||
public final static boolean setStackToSlots(ItemStack stack, List<ItemStack> stacks) {
|
public final static boolean setStackToSlots(ItemStack stack, List<ItemStack> stacks) {
|
||||||
for (ItemStack slot : stacks) {
|
for (ItemStack slot : stacks) {
|
||||||
|
Integer sum = stack.getCount() + slot.getCount();
|
||||||
if (slot.getItem().equals(stack.getItem())) {
|
if (slot.getItem().equals(stack.getItem())) {
|
||||||
slot.increment(stack.getCount());
|
if (slot.getItem().getMaxCount() >= sum) {
|
||||||
return true;
|
slot.increment(stack.getCount());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Integer transferSize = 64 - stack.getCount();
|
||||||
|
stack.setCount(stack.getCount() - transferSize);
|
||||||
|
slot.setCount(64);
|
||||||
|
// to not return sth. here so that the next loop will sum up the result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // if not found, seek for an empty stack instead
|
} // if not found, seek for an empty stack instead
|
||||||
for (ItemStack slot : stacks) {
|
for (ItemStack slot : stacks) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user