Search in sources :

Example 1 with ItemSnapshot

use of buildcraft.builders.item.ItemSnapshot in project BuildCraft by BuildCraft.

the class TileBuilder method onSlotChange.

@Override
protected void onSlotChange(IItemHandlerModifiable handler, int slot, @Nonnull ItemStack before, @Nonnull ItemStack after) {
    if (!world.isRemote) {
        if (handler == invSnapshot) {
            currentBasePosIndex = 0;
            snapshot = null;
            if (after.getItem() instanceof ItemSnapshot) {
                Snapshot.Header header = BCBuildersItems.snapshot.getHeader(after);
                if (header != null) {
                    Snapshot newSnapshot = GlobalSavedDataSnapshots.get(world).getSnapshot(header.key);
                    if (newSnapshot != null) {
                        snapshot = newSnapshot;
                    }
                }
            }
            updateSnapshot(true);
            sendNetworkUpdate(NET_SNAPSHOT_TYPE);
        }
        if (handler == invResources) {
            Optional.ofNullable(getBuilder()).ifPresent(SnapshotBuilder::resourcesChanged);
        }
    }
    super.onSlotChange(handler, slot, before, after);
}
Also used : ItemSnapshot(buildcraft.builders.item.ItemSnapshot) Snapshot(buildcraft.builders.snapshot.Snapshot) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) ItemSnapshot(buildcraft.builders.item.ItemSnapshot)

Aggregations

ItemSnapshot (buildcraft.builders.item.ItemSnapshot)1 Snapshot (buildcraft.builders.snapshot.Snapshot)1 SnapshotBuilder (buildcraft.builders.snapshot.SnapshotBuilder)1