This commit is contained in:
Mrbysco 2024-03-06 00:37:30 +01:00
commit 9f0a9926ac
2 changed files with 18 additions and 2 deletions

View file

@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.DrillItem; import de.ellpeck.actuallyadditions.mod.items.DrillItem;
import de.ellpeck.actuallyadditions.mod.items.Sack; import de.ellpeck.actuallyadditions.mod.items.Sack;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.sack.SackManager;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
@ -72,8 +73,12 @@ public class CommonEvents {
boolean changed = false; boolean changed = false;
boolean isVoid = ((Sack) invStack.getItem()).isVoid; boolean isVoid = ((Sack) invStack.getItem()).isVoid;
ItemStackHandlerAA inv = new ItemStackHandlerAA(28); //TODO whats going on here var optHandler = SackManager.get().getHandler(invStack);
DrillItem.loadSlotsFromNBT(inv, invStack);
if (optHandler.isEmpty())
continue;
ItemStackHandlerAA inv = optHandler.get();
FilterSettings filter = new FilterSettings(4, false, false); FilterSettings filter = new FilterSettings(4, false, false);
filter.readFromNBT(invStack.getOrCreateTag(), "Filter"); filter.readFromNBT(invStack.getOrCreateTag(), "Filter");

View file

@ -1,6 +1,7 @@
package de.ellpeck.actuallyadditions.mod.sack; package de.ellpeck.actuallyadditions.mod.sack;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -70,6 +71,16 @@ public class SackManager extends SavedData {
return Optional.empty(); return Optional.empty();
} }
public Optional<ItemStackHandlerAA> getHandler(ItemStack stack) {
if (stack.getOrCreateTag().contains("UUID")) {
UUID uuid = stack.getTag().getUUID("UUID");
if (data.containsKey(uuid))
return Optional.of(data.get(uuid).getSpecialHandler());
}
return Optional.empty();
}
public static SackManager load(CompoundTag nbt) { public static SackManager load(CompoundTag nbt) {
if (nbt.contains("Sacks")) { if (nbt.contains("Sacks")) {
ListTag list = nbt.getList("Sacks", CompoundTag.TAG_COMPOUND); ListTag list = nbt.getList("Sacks", CompoundTag.TAG_COMPOUND);